[R] Lavaan: Immediate non-positive definite matrix

2012-08-10 Thread Andrew Miles
ial data check. Any ideas what is happening, or what to do about it? Thanks. P.S. I haven't had success in attaching data files when I submit to the R help list, so if you would like the data please email me at andrewami...@hotmail.com. Andrew Miles [[alterna

Re: [R] FIML using lavaan returns zeroes for coefficients

2012-07-23 Thread Andrew Miles
Miles On Jul 21, 2012, at 12:59 PM, yrosseel wrote: > On 07/20/2012 10:35 PM, Andrew Miles wrote: >> Hello! >> >> I am trying to reproduce (for a publication) analyses that I ran >> several months ago using lavaan, I'm not sure which version, probably >>

[R] FIML using lavaan returns zeroes for coefficients

2012-07-20 Thread Andrew Miles
is happening, or how I can fix it? For those wishing to reproduce the problem, you can download a sample code file and data frame from the following two links. https://fds.duke.edu/db/aas/Sociology/grad/aam34/files/problem%20code.R https://fds.duke.edu/db/aas/Sociology/grad/aam34/files/sample

Re: [R] How do I obtain the current active path of a function that's being called?

2012-06-05 Thread Andrew Miles
y are treated as any other object, which is to say that you can only have one function of the same name at a time. Hence whenever you call a source file to load in function A, the old function A gets overwritten. Andrew Miles On Jun 5, 2012, at 4:58 PM, Michael wrote: > Hi all, > > H

Re: [R] Seeking pointers to various regression techniques with R?

2012-06-05 Thread Andrew Miles
) fits just the interaction between x and w without an intercept, and without the main effects for x and w lm(y ~ x/w - 1) I believe this fits the nested factor w inside of x Andrew Miles On Jun 5, 2012, at 4:58 PM, Michael wrote: > I read your website but still don't know the di

Re: [R] Higher log-likelihood in null vs. fitted model

2012-05-31 Thread Andrew Miles
e > likelihood out using > AIC is the issue ? ( AIC = -2 * likelihood + 2p so p - AIC/2 = > likelihood). AIC is a function of the likelihood but , as far as I know, > likelihood is not a function of the AIC. > Thanks for any insight. > > > > > > > On Thu

[R] Higher log-likelihood in null vs. fitted model

2012-05-31 Thread Andrew Miles
n advance for any input or references. Andrew Miles [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

Re: [R] Multivariate Multilevel Model: is R the right software for this problem

2012-04-06 Thread Andrew Miles
n the lme4 package, but has the advantage of being able to specify correlations between errors across time, the ability to control for time-invariant effects of time-invariant variables, and allows you to use the missing data maximum likelihood that comes in structural equation modeling packages. A

Re: [R] Multivariate Multilevel Model: is R the right software for this problem

2012-04-06 Thread Andrew Miles
kages. Andrew Miles Department of Sociology Duke University On Apr 6, 2012, at 9:48 AM, Eiko Fried wrote: > Hello, > > I've been trying to answer a problem I have had for some months now and > came across multivariate multilevel modeling. I know MPLUS and SPSS quite > well but

[R] FIML in R

2012-03-29 Thread Andrew Miles
'd be interested in updates on this, and in your thoughts on this more generally. Also, please let me know if there is a forum better suited for this kind of discussion. Andrew Miles __ R-help@r-project.org mailing list https://stat.ethz.ch/mailma

Re: [R] Help need

2012-02-07 Thread Andrew Miles
seq(0,0.5,0.1)) { sigmasqaured <- 1 i = complex(real = 0, imaginary = 1) spectrum <- c(spectrum, (sigmasqaured)/(abs(1-2.7607*exp(2*pi*i*f)+3.8106*exp(4*pi*i*f)-2.6535*exp(6*pi*i*f)+0.9258*exp(8*pi*i*f))^2)) } spectrum Andrew Miles On Feb 7, 2012, at 4:08 PM, Jaymi

Re: [R] fixed effects linear model in R

2012-02-07 Thread Andrew Miles
lopes varying randomly, etc.) See Allison's booklet for more details on this method. Allison, Paul D. 2009. Fixed Effects Regression Models. Los Angeles, C.A.: Sage. Andrew Miles On Feb 7, 2012, at 5:00 PM, caribou...@gmx.fr wrote: > Dear R-helpers, > > First of all, sorry for

Re: [R] Wide to long form conversion

2011-10-06 Thread Andrew Miles
Take a look here. http://stackoverflow.com/questions/2185252/reshaping-data-frame-from-wide-to-long-format Andrew Miles Department of Sociology Duke University On Oct 6, 2011, at 4:28 PM, Gang Chen wrote: > I have some data 'myData' in wide form (attached at the end), and &g

[R] mlogit error message "Error in X[omitlines, ] <- NA : subscript out of bounds"

2011-05-14 Thread Andrew Miles
that an answer to this question will be documented. Andrew Miles I am using the mlogit packages and get a data problem, for which I can't find any clue from R archive. code below shows my related code all the way to the

[R] Incorrect degrees of freedom in SEM model using lavaan

2011-03-17 Thread Andrew Miles
myCov, mimic.Mplus=FALSE) #check the number of parameters being estimated inspect(fit, what="free") #Note the DF for the Chi-square is 0, when it should be 28-13 = 15 summary(fit) Andrew Miles [[alternative HTML version deleted]] __

Re: [R] Regression Testing

2011-01-20 Thread Andrew Miles
Perhaps the easiest way to incorporate the heteroskedasticity consistent SE's and output them in a familiar and easy to interpret format is to use coeftest() in the lmtest package. coeftest(myModel, vcov=vcovHC(myModel)) Andrew Miles On Jan 20, 2011, at 4:42 PM, Achim Zeileis wrote:

Re: [R] memisc-Tables with robost standard errors

2011-01-05 Thread Andrew Miles
I always use apsrtable in the apsrtable package, which allows you to specify a vcov matrix using the "se" option. The only trick is that you have to append it to your model object, something like this: fit=lm(y ~ x) fit$se=vcovHC(fit) apsrtable(fit, se="robust") And

Re: [R] OT: Reducing pdf file size

2011-01-05 Thread Andrew Miles
I assume you mean PDFs generated by R. This topic has been addressed here: http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17475.html I have always just output the graphics then used an external PDF program (like Preview on the Mac) to do changes in file type, size reductions, etc. Andrew

Re: [R] robust standard error of an estimator

2011-01-01 Thread Andrew Miles
edasticity consistent SEs library(sandwich) library(lmtest) reg=lm(fsn~lctot) coeftest(reg, vcov=vcovHC(reg)) Or to get cluster robust SEs, check out this: people.su.se/~ma/ clustering.pdf Hope that helps. Andrew Miles On Jan 1, 2011, at 10:09 AM, Charlène Cosandier wrote: > Hi, > > I

Re: [R] After heteroskedasticity correction, how can I get new confidential interval?

2010-12-20 Thread Andrew Miles
It is hard to say without knowing more about the type of model you are running. A good place to look would be at the coeftest() function in the package lmtest. Andrew Miles On Dec 20, 2010, at 10:04 AM, JoonGi wrote: I just corrected std.error of my 'model'(Multi Regress

Re: [R] Title for y-axis on right side

2010-12-17 Thread Andrew Miles
Take a look at mtext() which offers options for writing text in any margin of the table. Andrew Miles On Dec 17, 2010, at 6:41 AM, phils_mu...@arcor.de wrote: Hi, I want to have a title for the y-axis on the right side of the plot. I know how to do it on the left side: title(ylab="

Re: [R] xyplot

2010-12-16 Thread Andrew Miles
Try sample() which will allow you to randomly select 10 ID's from your ID variable, which you can then plot. Andrew Miles On Dec 16, 2010, at 10:49 AM, Rasanga Ruwanthi wrote: Hi I am using following code to produce a xyplot for some longitudinal data. There are 2 panels. It pro

Re: [R] draw categorical histogram

2010-12-01 Thread Andrew Miles
ot;Helen", "Joe", "Kingston"), 50, replace=T) x=as.factor(x) plot(x) See also ?plot.factor Andrew Miles On Dec 1, 2010, at 4:06 PM, Jorge Ivan Velez wrote: Hi Phoebe, Try x <- c(12, 33, 56, 67, 15, 66) names(x) <- c('Richard','Minnie','A

Re: [R] draw categorical histogram

2010-12-01 Thread Andrew Miles
Try: plot (myCatVariable) Andrew Miles Department of Sociology Duke University On Dec 1, 2010, at 2:51 PM, phoebe kong wrote: Hi, Can someone tell me how to draw a histogram for the following summary? Richard Minnie Albert Helen Joe Kingston 1233 56 67

Re: [R] plot linear model problem

2010-11-16 Thread Andrew Miles
There may be an easier way to do this, but you could always just do it the long way. Ex. plot(residuals(test.lm)~fitted.values(test.lm)) Andrew Miles On Nov 16, 2010, at 5:01 PM, casperyc wrote: Hi all, Say I fit a linear model, and saved it as 'test.lm' Then if I use pl

Re: [R] Counting

2010-11-16 Thread Andrew Miles
the number of samples without the outlier N.nooutlier = Total - count Andrew Miles On Nov 16, 2010, at 4:55 PM, ufuk beyaztas wrote: Hi dear all, i have a data (data.frame) which contain y and x coloumn(i.e. y x 1 0.58545723 0.15113102 2 0.02769361 -0.02172165 3

Re: [R] Multiple imputation for nominal data

2010-11-02 Thread Andrew Miles
se articles can be found at the bottom of the help page that appears by typing ?mi OR for mice ?mice mi is the newer package and has some useful control features, but as it is newer it still is under development. Andrew Miles On Nov 2, 2010, at 3:38 PM, John Sorkin wrote: I am looking fo

Re: [R] Problem exporting data using write.foreign

2010-10-20 Thread Andrew Miles
ire_sp" after transformation. Simple, really, but frustrating until you get into the code and see what is happening, and how to isolate the offending variables. Andrew Miles On Oct 20, 2010, at 1:18 PM, Nordlund, Dan (DSHS/RDA) wrote: -Original Message- From: r-help-boun...@r

[R] Problem exporting data using write.foreign

2010-10-20 Thread Andrew Miles
where to go from here. What are the naming protocols for variables so that they can be exported using write.foreign()? Thanks! Andrew Miles __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the p

Re: [R] Many Thanks

2010-10-15 Thread Andrew Miles
And thank YOU for taking the time to express your gratitude. I'm sure all those who regularly take the time to contribute to the list appreciate the appreciation. Andrew Miles On Oct 15, 2010, at 9:49 AM, Jumlong Vongprasert wrote: Dear R-help mailing list and software development

Re: [R] R on a ma c

2010-10-14 Thread Andrew Miles
R works great on my Mac. In fact, the user interface in some ways seems to be more friendly (ex. you type an open parenthesis, it automatically includes a close parenthesis; color coding for coding files, etc.) Andrew Miles On Oct 14, 2010, at 2:49 PM, David Cross wrote: I have had no

Re: [R] how can i do anova

2010-10-11 Thread Andrew Miles
Type ?anova on your R command line for the basic function, and links to related functions. Also, try a google search of something like "doing anova in R" and you should find multiple tutorials or examples. Andrew Miles On Oct 11, 2010, at 11:33 AM, Mauluda Akhtar wrote: H

Re: [R] using a package function inside another function

2010-10-07 Thread Andrew Miles
Try adding a statement at the beginning of your function: require(micEcon) See if that helps. Andrew Miles Department of Sociology Duke University On Oct 7, 2010, at 11:47 AM, Alison Callahan wrote: Hello all, I am trying to use the micEcon 'insertRow' function inside a funct

Re: [R] statistic test plot

2010-09-27 Thread Andrew Miles
a sub- method for an htest object, so it probably doesn't know how to handle the type of data you are putting into it. Andrew Miles Department of Sociology Duke University On Sep 27, 2010, at 11:03 PM, Kie Kyon Huang wrote: Hi, I am a beginner in R and is trying to plot some dot plot fr

Re: [R] Sample size estimation for non-inferiority log-rank and Wilcoxon rank-sum tests

2010-09-27 Thread Andrew Miles
I haven't done much with the type of data you're working with, but here is a post that lists a few packages for doing sample size calculations in R. Perhaps one of them will be helpful. https://stat.ethz.ch/pipermail/r-help/2008-February/154223.html Andrew Miles On Sep 27, 2010,

[R] formatting data for predict()

2010-09-25 Thread Andrew Miles
iable called "dat" that contains two levels which represent my (modified) variables x1 and x2? Thanks in advance! Andrew Miles Department of Sociology Duke University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/

Re: [R] Multiple graph in one graph window

2010-09-24 Thread Andrew Miles
Another option is to use the par() command before executing a plot command, like so: par(mfrow=c(2,2)) plot(...) This will put the next four plots all in the same window. Andrew Miles Department of Sociology Duke University On Sep 24, 2010, at 10:28 PM, Dennis Murphy wrote: > Which one

Re: [R] bptest

2010-09-24 Thread Andrew Miles
First load the package lmtest. Then run the bptest. library(lmtest) bptest(modelCH) You don't need to tell the function which variables are explanatory or dependent. Just give it the fitted model object, and it will sort all of that out and return the statistic. Andrew Miles Depar

[R] Standard Error for difference in predicted probabilities

2010-09-24 Thread Andrew Miles
but how do I generate a SE for the difference in those predicted values? Thanks in advance! Andrew Miles [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the pos

[R] Error using the mi package

2010-07-15 Thread Andrew Miles
= info2, n.iter = 6, preprocess = FALSE) 1: mi(imp.data, info = info2, n.iter = 6, preprocess = FALSE) Andrew Miles __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-pro

Re: [R] Changing model parameters in the mi package

2010-07-14 Thread Andrew Miles
. You can add any other parameters that you want like so: info[["min.func"]]$params$MaxNWts=3000 This will add the parameter MaxNWts to the min.func model. This seems to have solved the problem I outlined below. Andrew Miles On Jul 14, 2010, at 10:33 AM, Andrew Miles wrote: I am try

[R] Changing model parameters in the mi package

2010-07-14 Thread Andrew Miles
default(X, Y, w, mask = mask, size = 0, skip = TRUE, softmax = TRUE, : too many (2608) weights System is Mac OS X 10.5.8, R version 2.9.2 Andrew Miles __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do r

Re: [R] how to plot two histograms overlapped in the same plane coordinate

2010-07-09 Thread Andrew Miles
'll probably have to manually alter the axes of the histogram to give the histograms for males and females the same break points (i.e. where one bar stops and another begins). See ?hist for more information about that. Andrew Miles Department of Sociology Duke University On Jul 9, 2010

Re: [R] how to calculate summary statistics for each factor

2010-07-06 Thread Andrew Miles
You could try Summarize in the NCStats package, or aggregate in the epicalc package. Andrew Miles Department of Sociology Duke University On Jul 6, 2010, at 11:53 AM, karena wrote: I have a dataset like the following: subject class value 123110 1241

Re: [R] Error message using mi() in mi package

2010-07-06 Thread Andrew Miles
On Jul 6, 2010, at 2:15 PM, Erik Iverson wrote: This looks suspiciously like a syntax problem. I would get my text editor to search for 'c14ordered' in the code. You might have missed some punctuation. -Peter Ehlers A good thought. I checked my own code (the stuff coding the data and u

Re: [R] Error message using mi() in mi package

2010-07-06 Thread Andrew Miles
On Jul 6, 2010, at 1:30 PM, Peter Ehlers wrote: On 2010-07-06 10:37, Andrew Miles wrote: Hello! I get the following message when I run the mi() function from the mi package. Error while imputing variable: c3 , model: mi.polr Error in eval(expr, envir, enclos) : could not find function

[R] Error message using mi() in mi package

2010-07-06 Thread Andrew Miles
re of the code and data involved. Any help would be appreciated, as I am not sure what is happening, and can't see why I can sometimes impute a variable labeled as "ordered- categorical" and sometimes cannot. Thanks! Andrew Miles

Re: [R] Interaction terms in logistic regression using glm

2010-04-30 Thread Andrew Miles
inear “Difference-in-Differences” Models" by Patrick A. Puhani. Did you find others? If you wouldn't mind sending along the citations for what you found, that would be very helpful. Many thanks! Andrew Miles On Apr 29, 2010, at 10:45 PM, Kjetil Halvorsen wrote: > see comments bel

[R] Interaction terms in logistic regression using glm

2010-04-28 Thread Andrew Miles
I seen the issue addressed in the forums or in the examples of logistic regression in R that I've found online. Thanks! Andrew Miles __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting gui

Re: [R] How to add a variable to a dataframe whose values are conditional upon the values of an existing variable

2010-02-26 Thread Andrew Miles
g 3 3 chick 4 mat$g=ifelse(mat$t=="cow", 1, 6) mat$g=ifelse(mat$t=="dog", 2, mat$g) mat$g=ifelse(mat$t=="chick", 3, mat$g) > mat t y g 1 cow 1 1 2 dog 3 2 3 chick 4 3 To days of the week would only be 7 statements. Andrew Miles Department of Sociology Duk

Re: [R] Weighted descriptives by levels of another variables

2009-11-16 Thread Andrew Miles
=function(df)wtd.mean(df$obese,df$sampwt); ddply(mydata, ~cut2(age,c(2,6,12,16)),'wtdmean') hth, david freedman Andrew Miles-2 wrote: I've noticed that R has a number of very useful functions for obtaining descriptive statistics on groups of variables, including summary {stats}, descr

[R] Weighted descriptives by levels of another variables

2009-11-14 Thread Andrew Miles
Again, my question is, does anybody know of a function that combines both the ability to provided weighted descriptives with the ability to subdivide by the levels of some other variable? Andrew Miles Department of Sociology Duke University [[alternative HTML version deleted]] _