[R] rjags error. Error parsing model file:,syntax error on line 5 near
Greetings, I am running a factor analysis model in rjags and have received the following error Error parsing model file: syntax error on line 5 near Line 5 is model { Here is my syntax. Any insight would be greatly appreciated. require(rjags) modelstring = model { for (i in 1 : nData) { for (j in 1 : nIndicators) { y[i,j] ~ dnorm(mu[i,j],psi[j]) ephat[i,j] - y[i,j] - mu[i,j] } mu[i,1] - alpha[1]+xi[i,1] # Factor 1 mu[i,2] - alpha[2]+lam[2]*xi[i,1] mu[i,3] - alpha[3]+lam[3]*xi[i,1] mu[i,4] - alpha[4]+lam[4]*xi[i,1] mu[i,5] - alpha[5]+lam[5]*xi[i,1] mu[i,6] - alpha[6]+lam[6]*xi[i,1] mu[i,7] - alpha[7]+lam[7]*xi[i,1] mu[i,8] - alpha[8]+lam[8]*xi[i,1] mu[i,9] - alpha[9]+xi[i,2]# Factor 2 mu[i,10] - alpha[10]+lam[10]*xi[i,2] mu[i,11] - alpha[11]+lam[11]*xi[i,2] mu[i,12] - alpha[12]+lam[12]*xi[i,2] mu[i,13] - alpha[13]+lam[13]*xi[i,2]] mu[i,14] - alpha[14]+lam[14]*xi[i,2] mu[i,15] - alpha[15]+lam[15]*xi[i,2] xi[i,1:2] ~ dmnorm(u[1:2],phi[1:2,1:2]) } for (j in 1:nIndicators) { alpha[j] ~ dnorm(0.0, 1.0) } #--- # Distributions and Priors #Priors on Loadings lam[2] ~ dnorm(0,psi[2]) lam[3] ~ dnorm(0,psi[3]) lam[4] ~ dnorm(0,psi[4]) lam[5] ~ dnorm(0,psi[5]) lam[6] ~ dnorm(0,psi[6]) lam[7] ~ dnorm(0,psi[7]) lam[8] ~ dnorm(0,psi[8]) lam[10] ~ dnorm(0,psi[10]) lam[11] ~ dnorm(0,psi[11]) lam[12] ~ dnorm(0,psi[12]) lam[13] ~ dnorm(0,psi[13]) lam[14] ~ dnorm(0,psi[14]) lam[15] ~ dnorm(0,psi[15]) #--- #Priors on Precisions for(j in 1:nIndicators) { psi[j] ~ dgamma(9.0, 4.0) # Error variances sgm[j] - 1/psi[j] } phi[1:2,1:2] ~ dwish(R[1:2,1:2], 5) # Precision matrix phx[1:2,1:2] - inverse(phi[1:2,1:2]) # Variance/Covariance matrix } writeLines(modelstring,con=model.txt) # # READ IN DATA AND PREPARE FOR JAGS cfadata = read.csv(~/Desktop/rjags stuff/nelsdata.csv,header=T) nData = NROW(cfadata) yname = c(getalong, spirit, discfair, friends, tchgood, tcherint, tchprais, tlisten, studisr, tputdown, strict, sputdown, notsafe, dislrn, getaway) y = as.matrix(cfadata) nData=NROW(y) nIndicators = NCOL(y) cfadata - list(y=y, nData=nData) #--- # A set of init statements goes here, but I haven't done that. #--- # RUN CHAIN parameters = c(lam[2],lam[3],lam[4]) adaptSteps = 500 burnInSteps = 500 nChains = 3 numSavedSteps = 5 thinSteps = 1 cfaModel = jags.model(model.txt,data=cfadata, n.chains=nChains, n.adapt=adaptSteps) # Burn-in: cat(Burning in the MCMC chain ...\n) update(cfaModel, n.iter=burnInSteps) cat(Sampling from the final MCMC chain ... \n) codaSamples = coda.samples(cfaModel, variable.names=parameters, n.iter=nPerChain, thin=thinSteps) -- == David Kaplan, Ph.D. Professor and Chair Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 880B 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage: edpsych.education.wisc.edu/people/faculty-staff/david-kaplan Project page: bise.wceruw.org Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Question about error message
Greetings, I'm getting this error message using Joe Shafer's NORM package. Error in storage.mode(x) - double : (list) object cannot be coerced to type 'double' I'm not sure what this means. I get this message when running s - prelim.norm(filename) prelim.norm is used to develop some summary statistics, etc. before implementing the EM algorithm for missing data. Please note that this is a data fusion exercise and there is considerable amounts of missing data by design. Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1082B 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 === [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Simple ordering or sorting question
Greetings, I'm trying to simply reorder a data frame on the row numbers. So, for example, instead of getting 1,2,3,4,5,6,7,8,9,10,11, ... 100 ..., I get instead 1, 10, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 11, ... I've tried commands such as df - df[order(rownames(df)),] and and have substituted the order command with sort and sort.list to no avail. Any advice would be appreciated. Thanks in advance. David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1082B 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 === [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple ordering or sorting question
That did it. Thanks!! David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1082B 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 === On 5/18/11 1:50 PM, jim holtman wrote: It looks like your row numbers are characters because that is the sort sequence you are getting. Try df- df[order(as.numeric(rownames(df))), ] On Wed, May 18, 2011 at 2:42 PM, David Kaplan dkap...@education.wisc.edu wrote: Greetings, I'm trying to simply reorder a data frame on the row numbers. So, for example, instead of getting 1,2,3,4,5,6,7,8,9,10,11, ... 100 ..., I get instead 1, 10, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 11, ... I've tried commands such as df- df[order(rownames(df)),] and and have substituted the order command with sort and sort.list to no avail. Any advice would be appreciated. Thanks in advance. David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1082B 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 === [[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 and provide commented, minimal, self-contained, reproducible code. [[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 and provide commented, minimal, self-contained, reproducible code.
[R] Question about is.na for missing data
Greetings, I am trying to a simple mean imputation using the following command (yes, I know it is not an ideal way to impute missing data) asd[is.na(asd)] - mean(asd,na.rm=TRUE) This has worked quite well in the past. Now, however, I am getting the following error messsage. Error in `[-.data.frame`(`*tmp*`, is.na(asd), value = c(2433.64150943396, : rhs is the wrong length for indexing by a logical matrix An inspection of the data set reveals no value of the sort give above. Any thoughts? Thanks in advance, David __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Simple question, I think
Greetings, I am recoding a dummy variable (coded 1,0) so that 0 = 2. I am using the line sciach$dummyba[sciach$ba==0] - 2 I notice that it creates a new column dummyba, with 0 coded as 2 but with 1's now coded as NA. Is there a simple way around this in the line I am using, or do I need to have an additional line sciach$dummyba[sciach$ba==1] - 1 Thanks in advance. David __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Multilevel models with sampling weights at both levels
Greetings, Is there a package in R that will run multilevel models (e.g. students nested in schools) where sampling weights can be employed at both levels? Thanks in advance. David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkaplan at education dot wisc dot edu homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Filling in a uniform dist plot
Hi all, Apologies in advance if this is really too simple, but I have given a good shot at this. I'm generating a standard uniform distibution y - dunif(x) plot(x,y,type=l) This will draw a horizontal line at y = 1. I want to fill the area from x=(0,1) with a color. I've tried the polygon command to create a polygon of the same shape, but can't seem to set the parameters to fill the figure from x=(0,1). I'm sure there is an easy way to do this, but any advice would be welcome. Thanks in advance. David __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Filling in a uniform dist plot
Yep. That's it. Thanks. David Peter Dalgaard wrote: David Kaplan wrote: Hi all, Apologies in advance if this is really too simple, but I have given a good shot at this. I'm generating a standard uniform distibution y - dunif(x) plot(x,y,type=l) This will draw a horizontal line at y = 1. I want to fill the area from x=(0,1) with a color. I've tried the polygon command to create a polygon of the same shape, but can't seem to set the parameters to fill the figure from x=(0,1). I'm sure there is an easy way to do this, but any advice would be welcome. Thanks in advance. Something like x - seq(0,1,,10) y - dunif(x) plot(x,y, ylim=range(0,y)) polygon(c(0,x,1), c(0,y,0), col=red, border=NA) David __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] plotting question
Greetings all, I have two questions. I have a data set that is arranged in the example below. I wish to obtain a plot of the performance of each ID over Year on v1. It's not clear how I set this up? ID Year V1 1 19801 1 19812 1 19826 1 19834 2 19805 2 19815 2 19825 2 19836 Also,I would like to transpose the data to have the variable across the columns such as ID v1980 v1981 v1982 v1983 1 1 2 6 4 2 5 5 5 6 Is there a straightforward way to do this in R? Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] overlay plot question
Greetings all, I have two logistic plots coming from two calls to plogis. The code is .x - seq(-7.6, 7.6, length=100) plot(.x, plogis(.x, location=0, scale=1), xlab=x, ylab=Density, main=Logistic Distribution: location = 0, scale = 1, type=l) abline(h=0, col=gray) .y - seq(-7.6, 7.6, length=100) plot(.x, plogis(.x, location=2, scale=4), xlab=x, ylab=Density, main=Logistic Distribution: location = 2, scale = 4, type=l) abline(h=0, col=gray) remove(.x) remove(.y) I would like to overlay these on one plot. Notice here the y-axis is different. But I would like to axis to be 0 to 1 as in the first plot. Any suggestions would be greatly appreciated. Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] help with predict in stats4
Hi, We're using stats4 for a logistic regression. The code is chdreg.logit2 - glm(chd ~ age + sex, family = binomial) summary(chdreg.logit2) oddsratios - coef(chdreg.logit2) exp(oddsratios) # Calculate model predicted values pred - predict(chdreg.logit2,type=response) The glm part runs fine, and up to now so has the predict function. However, now we're getting the following error Error in function (classes, fdef, mtable) : unable to find an inherited method for function predict, for signature glm Any thoughts about why this seems to now be appearing. Thanks in advance. -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] classification accuracy in logistic regression
Hi all, I'm looking for a program that will take the predicted probabilities from a logistic regression using glm{stats}, dichotomize them according to a threshold that I can control, and then use them to form sensitivity, specificity, false pos and false neg rates. Thanks in advance. David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Identify command in R
Hi all, In using the identify command, I get the following message plot(hatvalues(scireg3)) abline(h=.0154,lty=2) # plots a reference line at (k + 1)/n identify(1:1165, hatvalues(scireg3),row.names(sciach)) Error in xy.coords(x, y) : 'x' and 'y' lengths differ which doesn't allow me to see the observation number when I scroll over with the mouse. What exactly is this problem and is there a way to override it? Thanks in advance. -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Identify command in R]
Let me try to be more specific. The x y coordinates are different because of NAs in the dataset. In this analysis, a set of hat values (a measure of influence in regression) is given for each observation. On the basis of the regression that was run to get these hat values, the sample size was 1164 (one removed due to NA). The length of the data set is 1165. If I remove the NA from the data set, I can get identify to run. What I would like to know is if there is a way to get identify to ignore the NAs? Thanks in advance, -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Merging nested files
Greetings all, I have three files that I would like to merge. The first is a student level file that contains the student ID, their school ID, and their country ID. The second is the school file that contains the school ID and country ID. The third is the country file with a country ID. I would like to merge the three together using the common country ID. Of course, what this would mean is that school data be repeated for every student in their school, and country data repeated for every school and student in that country. Any direction would be helpful. Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Merging nested files
I think this will work. Thanks. But, is there a command to merge on a string variable. All I have is the country 3 letter designation. Thanks again, David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 === Erik Iverson wrote: Hello - David Kaplan wrote: Greetings all, I have three files that I would like to merge. The first is a student level file that contains the student ID, their school ID, and their country ID. The second is the school file that contains the school ID and country ID. The third is the country file with a country ID. I would like to merge the three together using the common country ID. Of course, what this would mean is that school data be repeated for every student in their school, and country data repeated for every school and student in that country. Any direction would be helpful. I believe what you are after is to use the merge function. 'merge' takes two data.frames, so to merge 3 data.frames, you'll have to use it twice. You may want the all = TRUE argument to merge also. Example, with your data.frames, it might look like: tmp - merge(student, school, all = TRUE) df - merge(tmp, country, all = TRUE) One thing to watch out for is that the merge function will merge on the common names in each data.frame, in your case country ID. Sometimes I check before the merge what variables it will attempt to merge on by using intersect(names(student), names(school)) and making sure it is what I expect, i.e. ususally only one common name. Hope that helps. Thanks in advance, David __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Handling complex sampling designs in R
Hi all, I typically need to analyze data from large scale surveys obtained under complex sampling designs and where sampling weights are provided. I suspect that weights can be handled for some, but not all, packages. Can someone point me to information about which packages can incorporate sampling weights? Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] derivatives and integrals in R
Hi all, Can anyone recommend a good reference for taking scalar and matrix derivatives in R, and also doing integration in R. I've searched the list and have not come across anything thus far. Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Handling complex sampling designs in R
This looks fantastic. Thanks! David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 === Tobias Verbeke wrote: Dear professor Kaplan, I typically need to analyze data from large scale surveys obtained under complex sampling designs and where sampling weights are provided. I suspect that weights can be handled for some, but not all, packages. Can someone point me to information about which packages can incorporate sampling weights? The most feature-rich package to analyze data originating from complex sampling designs is the survey package by Thomas Lumley. A feature list (as well as a wide assortment of package documentation) can be found at http://faculty.washington.edu/tlumley/survey/ The package itself can be installed from CRAN install.packages(survey) Kind regards, Tobias Verbeke __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] derivatives and integrals in R
__ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Handling complex sampling designs in R
__ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Error in Scan question
__ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Getting variable names from as.matrix
Hi all, I'm running a multidimensional scaling model on data that are first transformed into a similarity matrix using the program daisy in the cluster package. If I already provide the similarity matrix, the plotting routine will give me the variable names on the plot itself. But, it seems that when I use the daisy program to create the similarity matrix, I can't get the program to give me variable names on the plot. Here is the input ## Sammon's MDS country.demog - read.csv(~/Desktop/country.demog.csv) ## daisy requires loading the cluster package. It will calculate standardized Eculidean distances country.demog.dist - daisy(country.demog,metric=euclidean,stand=TRUE) ## The following line calculates the ordinal MDS country.mds - sammon(dist(country.demog.dist), k=2) ## The following lines create the MDS map using country names. It also places horizontal and vertical lines for reference. plot(country.mds$points,type=n) text(country.mds$points, labels = as.character(country.demog$country)) abline(h=0) abline(v=0) Thanks for any advice, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkaplan at education dot wisc dot edu homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Error message got a real'
Hi all, I'm running the program sem on a Mac, but I'm getting a message that I think is quite general. The error reads Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : scan() expected 'a real', got '10652)' The 10652 is the sample size coming from a .csv file where I have header = TRUE. Any thoughts would be appreciated. David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkaplan at education dot wisc dot edu homepage: [1]http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === References 1. http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error message got a real'
Thanks, I'm not sure why it wasn't saved as a .csv. I posted it to the R Mac list and the general R list because in the past when I've posted to the R Mac list I was told it wasn't a R question. Because this problem didn't appear with the windows verson of R, I wasn't sure which list was appropriate. There was no intention to be inconsiderate. David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkaplan at education dot wisc dot edu homepage: [1]http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Duncan Murdoch wrote: David Kaplan wrote: Yea, I checked that, but that wasn't the problem. I'm sending the input and a much smaller file. It's in .csv format. The input is for the Mac, and I'm beginning to think it might be a Mac issue. The program input lines come from John Fox's program sem The test.csv file isn't a csv file (which is a text format, with comma separated columns). It looks like your spreadsheet let you name it with extension .csv, but didn't save it in that format. By the way, posting the same question 6 minutes apart on two mailing lists is quite inconsiderate; please don't do that. Duncan Murdoch David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkaplan at education dot wisc dot edu homepage: [1][2]http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === Duncan Murdoch wrote: David Kaplan wrote: Hi all, I'm running the program sem on a Mac, but I'm getting a message that I think is quite general. The error reads Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : scan() expected 'a real', got '10652)' The 10652 is the sample size coming from a .csv file where I have header = TRUE. It appears to be finding a parenthesis too. That's not a real. Duncan Murdoch References 1. [3]http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm __ [EMAIL PROTECTED] mailing list [5]https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide [6]http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. References 1. http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm 2. http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm 3. http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm 4. mailto:R-help@r-project.org 5. https://stat.ethz.ch/mailman/listinfo/r-help 6. http://www.R-project.org/posting-guide.html __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Markov and Hidden Markov models
Hi, Is there a package that will estimate simple Markov models and hidden Markov models for discrete time processes in R? Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Moving to a Mac environment - quick question
Hi all, I'm moving to a Mac platform and have installed R and all seems fine. My question concerns moving my R objects over. On my pc, which file contains my R objects and once I copy that, where do I copy it within the Mac? I hope that was clear. Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: [2]http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 === References 1. mailto:[EMAIL PROTECTED] 2. http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] White's test again
Hi all, It seems that I can get White's (HC3) test using MASS. The syntax I used for the particular problem is anova(scireg3, white.adjust=hc3) where scireg3 is an object from the lm function. But, the anova summary table is all I get. I don't get the new estimates or standard errors correcting for heteroskedasticity. Is there a way to get that information? Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] A very simple question
Hi all, My apologies for a very simple question. I just downloaded R 2.6.0. I want to bring in all of the objects from 2.5.0 that I see when I type ls(). I have no idea how to do that. Thanks in advance. David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] Web: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 Fax: 608-262-0843 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Fatal error message in Windows version of 2.6
Hi, I opened up R 2.6 and now I am receiving a message that says Fatal Error: Unable to restore saved data in .RData When I look at the console I see a message that says Error in .Call(R_lazyLoadDBfetch,...) Any thoughts? David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] Web: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 Fax: 608-262-0843 __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question re matplot
Yea, sorry, that was a typo when I copied into my emal. Here it is again matplot(battingagg$X, battingagg[, c(HR,RBI,X2B, BB, R, SB)], type=b,lty=4,lwd=2, col=1:4,xlab = Year, ylab = (1)HRs, (2)RBIs, (3)DOUBLES,(4)BB,(5)Runs,(6) BB, pty=m,sub = Figure 2. Plot of Selected Offensive Baseball Statistics: 1901 - 2005) David === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] Web: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 Fax: 608-262-0843 === Marc Schwartz wrote: On Sat, 2007-10-13 at 22:00 -0500, David Kaplan wrote: Hi, I have the following script for matplot matplot(battingagg$X, battingagg[, c(HR,RBI,X2B, BB, R, SB)], type=b,lty=4,lwd=2, col=1:4,xlab = Year, ylab (1)HRs, (2)RBIs, (3)DOUBLES,(4)BB,(5)Runs,(6) BB, pty=m,sub = Figure 2. Plot of Selected Offensive Baseball Statistics: 1901 - 2005,) The problem I'm having is with ylab. It seems not to be giving the entire label, but rather cuts of the first 3 variables giving me only (4)BB,(5)Runs,(6) BB. How can I get it to print the entire label? Thanks in advance. David Is the above an exact copy of your script? If yes, what happens when you remember to put an '=' sign after 'ylab'? :-) Also, you appear to have a superfluous ',' at the end of the function call, prior to the final close paren. HTH, Marc Schwartz __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Missing data
I did. If you don't want to answer, then your unhelpful suggestions to yourself. === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room 1061 1025 W. Johnson Street Madison, WI 53706 email: [EMAIL PROTECTED] Web: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm Phone: 608-262-0836 Fax: 608-262-0843 === Bert Gunter wrote: Please use R's existing search tools before posting: RsiteSearch(imputation) RsiteSearch(missing data imputation) etc. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Kaplan Sent: Tuesday, September 11, 2007 2:36 PM To: [EMAIL PROTECTED] Subject: [R] Missing data Hi all, I'm looking for a contributed package that can provide a detailed account of missing data patterns and perhaps also provide imputation procedures, such as mean imputation or hot deck imputation and the like. Is there anything out there? Thanks in advance, David __ 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 and provide commented, minimal, self-contained, reproducible code.