[Depmix-commits] r186 - in trunk: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jun 24 23:02:55 CEST 2008
Author: ingmarvisser
Date: 2008-06-24 23:02:54 +0200 (Tue, 24 Jun 2008)
New Revision: 186
Modified:
trunk/NAMESPACE
trunk/R/freepars.R
trunk/man/responses.Rd
Log:
Modified: trunk/NAMESPACE
===================================================================
--- trunk/NAMESPACE 2008-06-24 16:04:19 UTC (rev 185)
+++ trunk/NAMESPACE 2008-06-24 21:02:54 UTC (rev 186)
@@ -7,7 +7,8 @@
makeMix,
lystig,
fb,
- forwardbackward,
+ forwardbackward,
+ MVNresponse,
llratio,
multinomial,
em,
Modified: trunk/R/freepars.R
===================================================================
--- trunk/R/freepars.R 2008-06-24 16:04:19 UTC (rev 185)
+++ trunk/R/freepars.R 2008-06-24 21:02:54 UTC (rev 186)
@@ -7,3 +7,20 @@
}
)
+# depends on nlin(object) and getpars(object)
+setMethod("freepars","depmix.fitted",
+ function(object) {
+ free <- sum(!getpars(object,which="fixed"))
+ free <- free-nlin(object) # FIX ME!!!!
+ free
+ }
+)
+
+# depends on nlin(object) and getpars(object)
+setMethod("freepars","mix.fitted",
+ function(object) {
+ free <- sum(!getpars(object,which="fixed"))
+ free <- free-nlin(object) # FIX ME!!!!
+ free
+ }
+)
\ No newline at end of file
Modified: trunk/man/responses.Rd
===================================================================
--- trunk/man/responses.Rd 2008-06-24 16:04:19 UTC (rev 185)
+++ trunk/man/responses.Rd 2008-06-24 21:02:54 UTC (rev 186)
@@ -106,49 +106,77 @@
\section{examples}{
mod <- GLMresponse(rnorm(1000)~1)
+
fit(mod)
mod <- GLMresponse(sample(1:3,1000,rep=TRUE)~1,family=multinomial())
+
fit(mod)
+
colSums(mod at y)/1000
x <- sample(0:1,1000,rep=TRUE)
+
mod <- GLMresponse(sample(1:3,1000,rep=TRUE)~x,family=multinomial(),pstart=c(0.33,0.33,0.33,0,0,1))
+
mod at y <- simulate(mod)
+
fit(mod)
+
colSums(mod at y[which(x==0),])/length(which(x==0))
+
colSums(mod at y[which(x==1),])/length(which(x==1))
x <- rnorm(1000)
+
library(boot)
+
p <- inv.logit(x)
+
ss <- rbinom(1000,1,p)
+
mod <- GLMresponse(cbind(ss,1-ss)~x,family=binomial())
+
fit(mod)
glm(cbind(ss,1-ss)~x, family=binomial)
x <- rnorm(1000,2)^2
+
res <- rpois(1000,x)
+
mod <- GLMresponse(res~x,family=poisson())
+
fit(mod)
glm(res~x, family=poisson)
x=runif(1000,1,5)
+
res <- rgamma(1000,x)
+
mod <- GLMresponse(res~x,family=Gamma())
+
fit(mod)
glm(res~x,family=Gamma)
library(mvtnorm)
+
mn <- c(1,2,3)
+
sig <- matrix(c(1,.5,0,.5,1,0,0,0,2),3,3)
+
y <- rmvnorm(1000,mn,sig)
- mod <- MVNresponse(y)
+
+ mod <- MVNresponse(y~1)
+
fit(mod)
+
+ colMeans(y)
+ var(y)
+
}
\author{Maarten Speekenbrink}
More information about the depmix-commits
mailing list