responses {depmixS4}R Documentation

Response models currently implemented in depmix.

Description

Depmix contains a number of default response models. We provide a brief description of these here.

BINOMresponse

BINOMresponse is a binomial response model. It derives from the basic GLMresponse class.

y:
The dependent variable can be either a binary vector, a factor, or a 2-column matrix, with successes and misses.
x:
The design matrix.
Parameters:
A named list with a single element ``coefficients'', which contains the GLM coefficients.

GAMMAresponse

GAMMAresponse is a model for a Gamma distributed response. It extends the basic GLMresponse class directly.

y:
The dependent variable.
x:
The design matrix.
Parameters:
A named list with a single element ``coefficients'', which contains the GLM coefficients.

MULTINOMresponse

MULTINOMresponse is a model for a multinomial distributed response. It extends the basic GLMresponse class, although the functionality is somewhat different from other models that do so.

y:
The dependent variable. This is a binary matrix with N rows and Y columns, where Y is the total number of categories.
x:
The design matrix.
Parameters:
A named list with a single element ``coefficients'', which is an ncol(x) by ncol(y) matrix which contains the GLM coefficients.

MVNresponse

MVNresponse is a model for a multivariate normal distributed response.

y:
The dependent variable. This is a matrix.
x:
The design matrix.
Parameters:
A named list with a elements ``coefficients'', which contains the GLM coefficients, and ``Sigma'', which contains the covariance matrix.

NORMresponse

NORMresponse is a model for a normal (Gaussian) distributed response. It extends the basic GLMresponse class directly.

y:
The dependent variable.
x:
The design matrix.
Parameters:
A named list with elements ``coefficients'', which contains the GLM coefficients, and ``sd'', which contains the standard deviation.

POISSONresponse

POISSONresponse is a model for a Poisson distributed response. It extends the basic GLMresponse class directly.

y:
The dependent variable.
x:
The design matrix.
Parameters:
A named list with a single element ``coefficients'', which contains the GLM coefficients.

Author(s)

Maarten Speekenbrink & Ingmar Visser

Examples

        
        # binomial response model
        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)
        
        # gamma response model
        x=runif(1000,1,5)
        res <- rgamma(1000,x)
        ## note that gamma needs proper starting values which are not
        ## provided by depmixS4 (even with them, this may produce warnings)
        mod <- GLMresponse(res~x,family=Gamma(),pst=c(0.8,1/0.8))
        fit(mod)
        glm(res~x,family=Gamma)
        
        # multinomial response model
        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@y <- simulate(mod)
        fit(mod)
        colSums(mod@y[which(x==0),])/length(which(x==0))
        colSums(mod@y[which(x==1),])/length(which(x==1))
        
        # multivariate normal response model
        mn <- c(1,2,3)
        sig <- matrix(c(1,.5,0,.5,1,0,0,0,2),3,3)
        y <- mvrnorm(1000,mn,sig)
        mod <- MVNresponse(y~1)
        fit(mod)
        colMeans(y)
        var(y)
        
        # normal (gaussian) response model
        y <- rnorm(1000)
        mod <- GLMresponse(y~1)
        fm <- fit(mod)
        cat("Test gaussian fit: ", all.equal(getpars(fm),c(mean(y),sd(y)),check=FALSE))
        
        
        # poisson response model
        x <- abs(rnorm(1000,2))
        res <- rpois(1000,x)
        mod <- GLMresponse(res~x,family=poisson())
        fit(mod)
        glm(res~x, family=poisson)
        

[Package depmixS4 version 0.2-1 Index]