Last data update: 2014.03.03

R: Convert states to vector of probabilities of any given state
states2probsR Documentation

Convert states to vector of probabilities of any given state

Description

Converts states (either as a size N array of labels or an N \times K weight matrix) into N probabilities per state.

If states is a matrix - representing the state space in the dimensions of the original data - then the probabilities will be formatted automatically to an array of the same shape and dimension.

Usage

states2probs(weight.matrix = NULL, states = NULL, type = "MLE")

Arguments

states

array of size N with entry i being the label k = 1, …, K of PLC i

weight.matrix

N \times K weight matrix

type

estimation type for the probabilities: c("MLE")

See Also

weight_matrix2states

Examples

state.sim <- sample.int(5, 100, replace = TRUE)
prob.state <- states2probs(states = state.sim)
layout(matrix(1:2, ncol = 2))
plot(state.sim, xlab = "", ylab = "state")
plot(prob.state, xlab = "", ylab = "probability")
plot(state.sim, prob.state, xlab = "state", ylab = "probability", type = "h")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LSC)
Loading required package: LICORS
Loading required package: RColorBrewer
Loading required package: fields
Loading required package: spam
Loading required package: grid
Spam version 1.3-0 (2015-10-24) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction 
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.

Attaching package: 'spam'

The following objects are masked from 'package:base':

    backsolve, forwardsolve

Loading required package: maps

 # maps v3.1: updated 'world': all lakes moved to separate new #
 # 'lakes' database. Type '?world' or 'news(package="maps")'.  #


Loading required package: gam
Loading required package: splines
Loading required package: foreach
Loaded gam 1.12

Loading required package: Matrix
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LSC/states2probs.Rd_%03d_medium.png", width=480, height=480)
> ### Name: states2probs
> ### Title: Convert states to vector of probabilities of any given state
> ### Aliases: states2probs
> ### Keywords: manip
> 
> ### ** Examples
> 
> state.sim <- sample.int(5, 100, replace = TRUE)
> prob.state <- states2probs(states = state.sim)
> layout(matrix(1:2, ncol = 2))
> plot(state.sim, xlab = "", ylab = "state")
> plot(prob.state, xlab = "", ylab = "probability")
> plot(state.sim, prob.state, xlab = "state", ylab = "probability", type = "h")
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>