similar to: controling omitted category in factor()

Displaying 20 results from an estimated 10000 matches similar to: "controling omitted category in factor()"

2007 Nov 13
1
FW: Reference category for explanatory factors
(Oops first mistake was posting to the wrong area) I am not sure what is needed to be posted in terms of what I have done but will explain nonetheless. I am using the msm.package and trying to specify my reference category for an outcome covariate. The following command line works: ## age of respondent - using year5a: categorical preg_fyear5a.msm<-msm(outcome~ipi, subject=id, data,
2010 Jul 07
6
forcing a zero level in contr.sum
I need to use contr.sum and observe that some levels are not statistically different from the overall mean of zero. What is the proper way of forcing the zero estimate? It seems the column corresponding to that level should become a column of zeros. Is there a way to achieve that without me constructing the design matrix? Thank you. Stephen Bond [[alternative HTML version deleted]]
2005 Feb 23
1
model.matrix for a factor effect with no intercept
I was surprised by this (in R 2.0.1): > a <- ordered(-1:1) > a [1] -1 0 1 Levels: -1 < 0 < 1 > model.matrix(~ a) (Intercept) a.L a.Q 1 1 -7.071068e-01 0.4082483 2 1 -9.073800e-17 -0.8164966 3 1 7.071068e-01 0.4082483 attr(,"assign") [1] 0 1 1 attr(,"contrasts") attr(,"contrasts")$a [1]
2007 Mar 09
2
piecing together statements (macro?)
Hi All I am pretty new to R but saw stata and sas's macro facilities and am looking for how such things work in R. I am trying to piece together a series of statements: n = 5 #want to have it dynamic with respect to n for (j in 1:n) { eval(paste("x", j, "=x[", j, "]", sep="")) } I want the created statements 'x1=x[1]' immediately executed
2007 Jul 21
2
avoiding timconsuming for loop renaming identifiers
Hi All I was wondering if I can avoid a time-consuming for loop on my 600000 obs dataset. school_id y 8 9.87 8 8.89 8 7.89 8 8.88 20 6.78 20 9.99 20 8.79 31 10.1 31 11 There are, say, 143 different schools in this 600000 obs dataset. I need to thave sequential identifiers, 1,2,3,4,5,...,143. I was using an
2007 Jun 01
2
how to specify starting values in varIdent() of lme()
I was reading the help but just did not get how to specify starting values for varIdent() of the lme() function, although I managed to do it for corSymm(). Do I specify the values just as they are printed out in an output, like c(1, 1.3473, 1.0195). Or do I need to take the residual and multiply it with these like c(0.2235, 0.2235*1.3473, 0.2235*1.0195) or any other form that I dont know of?
2019 Aug 31
2
inconsistent handling of factor, character, and logical predictors in lm()
Dear Abby, > On Aug 30, 2019, at 8:20 PM, Abby Spurdle <spurdle.a at gmail.com> wrote: > >> I think that it would be better to handle factors, character predictors, and logical predictors consistently. > > "logical predictors" can be regarded as categorical or continuous (i.e. 0 or 1). > And the model matrix should be the same, either way. I think that
2019 Aug 30
3
inconsistent handling of factor, character, and logical predictors in lm()
Dear R-devel list members, I've discovered an inconsistency in how lm() and similar functions handle logical predictors as opposed to factor or character predictors. An "lm" object for a model that includes factor or character predictors includes the levels of a factor or unique values of a character predictor in the $xlevels component of the object, but not the FALSE/TRUE values
2007 May 23
2
saving datafreame object problem
Do I miss here something? dtaa = read.table("http://www.ats.ucla.edu/stat/mplus/examples/ma_snijders/mlbook1.dat", sep=",") head(dtaa) # shows the data as it should be save(dtaa,"dtaa",file="c:/dtaa") d = load("c:/dtaa") head(d) # all data is lost, it only shows [1] "dtaa" "dtaa" Thanks for your hint on this.
2007 Oct 29
1
lm design matrix bug?
Hi All Maybe I dont understand it, but I would have expected that the design matrix has as many rows as there were observations available to fit the model. Below a small artificial dataset created, then one model fitted and the design matrix outputted, having 27 rows. Then I delete 6 obs, and fit the model on these 21 obs, but the design matrix that comes out has 26 rows? Thanks for your
2007 May 21
1
can I get same results using lme and gls?
Hi All I was wondering how to get the same results with gls and lme. In my lme, the design matrix for the random effects is (should be) a identity matrix and therefore G should add up with R to produce the R matrix that gls would report (V=ZGZ'+R). Added complexity is that I have 3 levels, so I have R, G and say H (V=WHW'+ZGZ'+R). The lme is giving me the correct results, I am
2007 Jul 06
1
maintaining specified factor contrasts when subsetting in lmer
All, I'm using lmer for some repeated measures data and have specified the contrasts for a time factor such that say time 3 is the base. This works fine. However, when I next use the subset argument to remove the last two time values, the output indicates that the specified contrast is not maintained (see below). I can solve this by creating a new dataframe for the subset of interest
2006 Aug 17
1
Setting contrasts for polr() to get same result of SAS
Hi all, I am trying to do a ordered probit regression using polr(), replicating a result from SAS. >polr(y ~ x, dat, method='probit') suppose the model is y ~ x, where y is a factor with 3 levels and x is a factor with 5 levels, To get coefficients, SAS by default use the last level as reference, R by default use the first level (correct me if I was wrong), The result I got is a
2007 Aug 07
1
R2WinBUGS results not different with different runs
Hi All I dont know if anyone else has noticed the same thing, but with 2 subsequent runs of the same syntax, I am getting exactly the same results. I was expecting that results differ slighlty, say in the 4th or 5th decimal place. Is this a specialty with R2WinBUGS? Does it have something to do with the seed value? Isnt the seed value reset everytime I restart winbugs? Thanks Toby
2007 Jul 21
1
R2WinBUGS awkward to use
Hi All Does anyone know if I can avoid to use the write.model() function below? I dont want to do this. Can't bugs() do that automatically for me just by specifying the 4th argument 'model'? Just I like I am also using the 'inits' object! If I use 'model' in the same way as I use 'inits' I am getting the error: > sim <- bugs(data, inits, parameters,
2009 Jan 23
2
Categorical Variables and glm()
When including categorical variables in a regression, the default in R is to set the first level as the base. Is there an option to specify a different level as the base? Regards, Stephen Collins, MPP | Analyst Health & Benefits | Aon Consulting [[alternative HTML version deleted]]
2007 Jun 21
2
Multinomial models
Hello, I am VERY new to R (one week) and I am trying to run a multinomial logit model. The model I am using is > model1 <- multinom(Y ~ X1 + X2 + , ..., Xn) if I put in > summary(model1) I get #Error in function (classes, fdef, mtable) : unable to find an inherited method for function "fitted", for signature "multinom" and if I put in > coef(model1)
2010 Jul 21
1
lm: order of dropped columns
Hi all, If presented with a singular design matrix, lm drops columns to make the design matrix non-singular. What algorithm is used to select which (and how many) column(s) to drop? Particularly, given a factor, how does lm choose levels of the factor to discard? Thanks for the help. Best, Anirban [[alternative HTML version deleted]]
2010 Aug 03
1
releveling a numeric by factor interaction
Can anyone help me with the necessary code to relevel a numeric*factor interaction term in a linear model? I would like to report the estimate, std. error and t-value for the reference factor. First, I estimated a linear model with dummy variables and was able to retrieve model estimates for the reference factor using relevel. for example: > summary(update(mod.mod, . ~ . - dummy + +
2007 Jun 28
2
logistic regression and dummy variable coding
Hello everyone, I have a variable with several categories and I want to convert this into dummy variables and do logistic regression on it. I used model.matrix to create dummy variables but it always picked the smallest one as the reference. For example, model.matrix(~.,data=as.data.frame(letters[1:5])) will code 'a' as '0 0 0 0'. But I want to code another category as