SCM

SCM Repository

[depmix] Annotation of /pkg/man/responses.Rd
ViewVC logotype

Annotation of /pkg/man/responses.Rd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 203 - (view) (download) (as text)

1 : maarten 201 \name{responses}
2 :    
3 :     \alias{responses}
4 :    
5 :     \alias{BINOMresponse}
6 :     \alias{GAMMAresponse}
7 :     \alias{MULTINOMresponse}
8 :     \alias{MVNresponse}
9 :     \alias{NORMresponse}
10 :     \alias{POISSONresponse}
11 :    
12 :     \alias{show,MVNresponse-method}
13 :    
14 :     \title{Response models currently implemented in depmix.}
15 :    
16 :     \description{Depmix contains a number of default response models. We provide a
17 :     brief description of these here.}
18 :    
19 :     \section{BINOMresponse}{
20 :    
21 :     \code{BINOMresponse} is a binomial response model. It derives from the basic
22 :     \code{\link{GLMresponse}} class.
23 :    
24 :     \describe{
25 :     \item{y:}{The dependent variable can be either a
26 :     binary vector, a factor, or a 2-column matrix, with successes and misses.}
27 :     \item{x:}{The design matrix.}
28 :     \item{Parameters:}{A named list with a single element ``coefficients'',
29 :     which contains the GLM coefficients.}
30 :     }
31 :    
32 :     }
33 :    
34 :     \section{GAMMAresponse}{
35 :    
36 :     \code{GAMMAresponse} is a model for a Gamma distributed response.
37 :     It extends the basic \code{\link{GLMresponse}} class directly.
38 :    
39 :     \describe{
40 :     \item{y:}{The dependent variable.}
41 :     \item{x:}{The design matrix.}
42 :     \item{Parameters:}{A named list with a single element ``coefficients'',
43 :     which contains the GLM coefficients.}
44 :     }
45 :    
46 :     }
47 :    
48 :     \section{MULTINOMresponse}{
49 :    
50 :     \code{MULTINOMresponse} is a model for a multinomial distributed response.
51 :     It extends the basic \code{\link{GLMresponse}} class, although the
52 :     functionality is somewhat different from other models that do so.
53 :    
54 :     \describe{
55 :     \item{y:}{The dependent variable. This is a binary matrix with N rows and
56 :     Y columns, where Y is the total number of categories.}
57 :     \item{x:}{The design matrix.}
58 :     \item{Parameters:}{A named list with a single element ``coefficients'',
59 :     which is an \code{ncol(x)} by \code{ncol(y)} matrix which contains the GLM
60 :     coefficients.}
61 :     }
62 :    
63 :     }
64 :    
65 :     \section{MVNresponse}{
66 :    
67 :     \code{MVNresponse} is a model for a multivariate normal distributed response.
68 :    
69 :     \describe{
70 :     \item{y:}{The dependent variable. This is a matrix.}
71 :     \item{x:}{The design matrix.}
72 :     \item{Parameters:}{A named list with a elements ``coefficients'',
73 :     which contains the GLM coefficients, and ``Sigma'', which contains the
74 :     covariance matrix.}
75 :     }
76 :    
77 :     }
78 :    
79 :     \section{NORMresponse}{
80 :    
81 :     \code{NORMresponse} is a model for a normal (Gaussian) distributed response.
82 :     It extends the basic \code{\link{GLMresponse}} class directly.
83 :    
84 :     \describe{
85 :     \item{y:}{The dependent variable.}
86 :     \item{x:}{The design matrix.}
87 :     \item{Parameters:}{A named list with elements ``coefficients'',
88 :     which contains the GLM coefficients, and ``sd'', which contains the
89 :     standard deviation.}
90 :     }
91 :    
92 :     }
93 :    
94 :     \section{POISSONresponse}{
95 :    
96 :     \code{POISSONresponse} is a model for a Poisson distributed response.
97 :     It extends the basic \code{\link{GLMresponse}} class directly.
98 :    
99 :     \describe{
100 :     \item{y:}{The dependent variable.}
101 :     \item{x:}{The design matrix.}
102 :     \item{Parameters:}{A named list with a single element ``coefficients'',
103 :     which contains the GLM coefficients.}
104 :     }
105 :    
106 :     }
107 :    
108 :     \section{examples}{
109 :    
110 :     mod <- GLMresponse(rnorm(1000)~1)
111 :    
112 :     fit(mod)
113 :    
114 :     mod <- GLMresponse(sample(1:3,1000,rep=TRUE)~1,family=multinomial())
115 :    
116 :     fit(mod)
117 :    
118 :     colSums(mod@y)/1000
119 :    
120 :     x <- sample(0:1,1000,rep=TRUE)
121 :    
122 :     mod <- GLMresponse(sample(1:3,1000,rep=TRUE)~x,family=multinomial(),pstart=c(0.33,0.33,0.33,0,0,1))
123 :    
124 :     mod@y <- simulate(mod)
125 :    
126 :     fit(mod)
127 :    
128 :     colSums(mod@y[which(x==0),])/length(which(x==0))
129 :    
130 :     colSums(mod@y[which(x==1),])/length(which(x==1))
131 :    
132 :     x <- rnorm(1000)
133 :    
134 :     library(boot)
135 :    
136 :     p <- inv.logit(x)
137 :    
138 :     ss <- rbinom(1000,1,p)
139 :    
140 :     mod <- GLMresponse(cbind(ss,1-ss)~x,family=binomial())
141 :    
142 :     fit(mod)
143 :    
144 :     glm(cbind(ss,1-ss)~x, family=binomial)
145 :    
146 :     x <- abs(rnorm(1000,2))
147 :    
148 :     res <- rpois(1000,x)
149 :    
150 :     mod <- GLMresponse(res~x,family=poisson())
151 :    
152 :     fit(mod)
153 :    
154 :     glm(res~x, family=poisson)
155 :    
156 :     x=runif(1000,1,5)
157 :    
158 :     res <- rgamma(1000,x)
159 :    
160 : maarten 203 ## note that gamma needs proper starting values which are not
161 :     ## provided by depmixS4 (even with them, this may produce warnings)
162 : maarten 201 mod <- GLMresponse(res~x,family=Gamma(),pst=c(0.8,1/0.8))
163 :    
164 :     fit(mod)
165 :    
166 :     glm(res~x,family=Gamma)
167 :    
168 :     mn <- c(1,2,3)
169 :    
170 :     sig <- matrix(c(1,.5,0,.5,1,0,0,0,2),3,3)
171 :    
172 :     y <- mvrnorm(1000,mn,sig)
173 :    
174 :     mod <- MVNresponse(y~1)
175 :    
176 :     fit(mod)
177 :    
178 :     colMeans(y)
179 :    
180 :     var(y)
181 :    
182 :     }
183 :    
184 :     \author{Maarten Speekenbrink}
185 :    
186 :     \keyword{models}

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge