responses              package:depmixS4              R Documentation

_R_e_s_p_o_n_s_e _m_o_d_e_l_s _c_u_r_r_e_n_t_l_y _i_m_p_l_e_m_e_n_t_e_d _i_n _d_e_p_m_i_x.

_D_e_s_c_r_i_p_t_i_o_n:

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

_B_I_N_O_M_r_e_s_p_o_n_s_e:

     '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.

     _P_a_r_a_m_e_t_e_r_s: A named list with a single element ``coefficients'',
          which contains the GLM coefficients.

_G_A_M_M_A_r_e_s_p_o_n_s_e:

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


     _y: The dependent variable.

     _x: The design matrix.

     _P_a_r_a_m_e_t_e_r_s: A named list with a single element ``coefficients'',
          which contains the GLM coefficients.

_M_U_L_T_I_N_O_M_r_e_s_p_o_n_s_e:

     '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.

     _P_a_r_a_m_e_t_e_r_s: A named list with a single element ``coefficients'',
          which is an 'ncol(x)' by 'ncol(y)' matrix which contains the
          GLM coefficients.

_M_V_N_r_e_s_p_o_n_s_e:

     'MVNresponse' is a model for a multivariate normal distributed
     response.


     _y: The dependent variable. This is a matrix.

     _x: The design matrix.

     _P_a_r_a_m_e_t_e_r_s: A named list with a elements ``coefficients'', which
          contains the GLM coefficients, and ``Sigma'', which contains
          the covariance matrix.

_N_O_R_M_r_e_s_p_o_n_s_e:

     '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.

     _P_a_r_a_m_e_t_e_r_s: A named list with elements ``coefficients'', which
          contains the GLM coefficients, and ``sd'', which contains the
          standard deviation.

_P_O_I_S_S_O_N_r_e_s_p_o_n_s_e:

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


     _y: The dependent variable.

     _x: The design matrix.

     _P_a_r_a_m_e_t_e_r_s: A named list with a single element ``coefficients'',
          which contains the GLM coefficients.

_A_u_t_h_o_r(_s):

     Maarten Speekenbrink & Ingmar Visser

_E_x_a_m_p_l_e_s:

             
             # 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)
             

