Re: [R] R ANOVA gives diferent results than SPSS
I have found a similar problem with the ANOVA function in R, I found the problem is when you specify a variable in SPSS as a random variable instead of fixed, and R treats all of the factors as fixed. Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Greg Snow Sent: Thursday, February 11, 2010 10:45 AM To: Protzko; r-help@r-project.org Subject: Re: [R] R ANOVA gives diferent results than SPSS A couple of possibilities: The data is not the same, e.g. something in the file was interpreted differently by the 2 programs, one of the programs may have stopped reading at an unrecognized value, while the other skipped it and went on. Or it used to be common to encode missing values as -999, if one program recognizes that as missing, but you did not tell the other one too, then it could treat that as a legitimate value. The model is not the same, e.g. one program may be interpreting your grouping variable as a continuous variable and the other as categorical, which would result in 2 very different models and outcomes. If you show us your data/code/output as has been requested, then we may be able to tell which it is. Without that information you are expecting either R or the members of the list to read your mind. I keep making notes to my future self to use the timetravel package (not written yet, that's why I need my future self to use it) to send a copy of the esp package (also not written yet) back in time to me so I can use it for situations like this. But so far that has not worked (maybe my future self is even more lazy than my present self, or my near future self does something to offend my far future self enough that he is unwilling to do this small favor for my current past self, darn, either way means I should probably do better on the diet/exercise). The short version of the above rambling is that we want to help, but cannot help you until you help us to help you. Show us your data/code/output (or data/code/output for simulated/example data if you can't show your real data). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Protzko > Sent: Thursday, February 11, 2010 9:38 AM > To: r-help@r-project.org > Subject: Re: [R] R ANOVA gives diferent results than SPSS > > > a one-way ANOVA should be a one-way ANOVA I guess, model is simple > enough I > thought. The F value seems pretty clear, I'm doing nothing fancy here, > just > trying to figure out how to do in R what I'm doing in SPSS. > -- > View this message in context: http://n4.nabble.com/R-ANOVA-gives- > diferent-results-than-SPSS-tp1477322p1477468.html > Sent from the R help mailing list archive at Nabble.com. > > __ > 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-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] Multiple missing values
Gary King's Amelia package for R and a stand alone version does EM algorithm multiple imputation. Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Frank E Harrell Jr Sent: Sunday, February 14, 2010 9:39 AM To: Patrick Burns Cc: r-help@r-project.org; john.macin...@ed.ac.uk Subject: Re: [R] Multiple missing values Patrick Burns wrote: > I can think of a few solutions, none perfect. > > * You could have a master dataset that has the > missing value codes you want, and a dataset that > you use which is a copy of it with real NA's in it. > > * You could add an attribute that gives the types > of missing values in the various positions. The > downside is that attributes tend to disappear with > subsetting. The sas.get function in the Hmisc exemplifies that approach, and it has a subsetting method that preserves the special.miss attribute. Frank > > * If you only have two types, you might be able to > get away with using NaN as the second type of NA. > > On 14/02/2010 14:33, John wrote: >> Does anyone know, or know documentation that describes, how to declare >> multiple values in R as missing that does not involve coding them as >> NA? I >> wish to be able to treate values as missing, while still retaining codes >> that describe the reason for the value being missing. >> >> Thanks >> >> John MAcInnes >> >> >> -- Frank E Harrell Jr Professor and ChairmanSchool of Medicine Department of Biostatistics Vanderbilt University __ 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] opacity under dispersion command under plotrix
Is there anyway to make the lines in the dispersion command come forward in a plot and allow the fill in the dispersion parameter be transparent so all of the lines I am using to note confidence intervals are shown? --- Joe King, M.A. Ph.D. Student University of Washington - Seattle 206-913-2912 j...@joepking.com --- "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt [[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] opacity under dispersion command under plotrix
Heres my code: era1 <- seq(1.5,5,.25) plot(era1,yhyp1$pe, xlab="ERA", ylab="Probability of Winning Cy Young",type="l", col="black", lwd=2) dispersion(era1,yhyp1$pe,y1upper,y1lower,type="l", fill="blue",arrow.cap=0.01,intervals=FALSE)#Requres plotrix dispersion(era1,yhyp2$pe,y2upper,y2lower,type="l", fill="lightcyan",arrow.cap=0.01,intervals=FALSE)#Requres plotrix dispersion(era1,yhyp3$pe,y3upper,y3lower,type="l", fill="gray97",arrow.cap=0.01,intervals=FALSE)#Requres plotrix lines(era1,yhyp1$pe,col="black", lwd=5) lines(era1,yhyp2$pe,col="blue", lwd=5) lines(era1,yhyp3$pe,col="red", lwd=5) my raw data is too much to add as I have coefficients from a model run and a lot of code before that but the matricies for the above variables I am trying to plot are > yhyp1$pe [1] 0.91938328 0.88005171 0.82235810 0.74124787 0.63520716 0.51090516 [7] 0.38417025 0.27254070 0.18569395 0.12375682 0.08183003 0.05420338 [13] 0.03619331 0.02446051 0.01677548 > yhyp1$upper [,1] up 0.98470376 up 0.96729674 up 0.93342185 up 0.87016432 up 0.77356024 up 0.63337489 up 0.49704477 up 0.39523107 up 0.32380653 up 0.26340188 up 0.21370693 up 0.17113476 up 0.13810301 up 0.9516 up 0.08930777 > yhyp1$lower [,1] low 0.758338075 low 0.704684752 low 0.636448570 low 0.569633622 low 0.485986148 low 0.390656111 low 0.276924551 low 0.169273771 low 0.092501362 low 0.048176412 low 0.023014862 low 0.010788438 low 0.005082446 low 0.002250877 low 0.001063545 Please forgive my poor posting manners. Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Friday, October 30, 2009 7:15 AM To: Joe King Cc: r-help@r-project.org Subject: Re: [R] opacity under dispersion command under plotrix On Oct 30, 2009, at 7:02 AM, Joe King wrote: > Is there anyway to make the lines in the dispersion command come > forward in > a plot and allow the fill in the dispersion parameter be transparent > so all > of the lines I am using to note confidence intervals are shown? Got code? > --- > > Joe King, M.A. > > Ph.D. Student -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Frequency
sorry, I forgot to send my reply to the list, I got to remember to hit reply all: So I set up a dummy matrix, v1,v2,v3,v4, an datamatrix v1 = c(5,3,4) v2 = c(6,4,6) v3 = c(9,7,10) v4 = c(10,10,18) datamatrix=c(v1,v2,v3,v4) then do sort(table(datamatrix)) Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Val Sent: Monday, November 02, 2009 10:35 AM To: r-help@r-project.org Subject: [R] Frequency BAYESIAN INFERENCES FOR MILKING TEMPERAMENT IN CANADIAN HOLSTEINS Hi All, I have a data set "x" with several variables. Sample of the data is shown below V1 v2 v3 v4 569 10 347 10 46 10 18 I want the frequency of each data point sorted by their occurrence. Below is the output that I want 10=3 6=2 4=2 9=1 5=1 7=1 3=1 How do I do it in R? Thanks in advance Val [[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-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] problems with read.csv
I use indata = read.csv(file.choose(),header=TRUE) of course you can specify your file. Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Fang (Betty) Yang Sent: Monday, November 02, 2009 1:10 PM To: r-help@r-project.org Subject: [R] problems with read.csv Dear all, I'd like to ask help on R code to get the same results as the following Splus code: >indata<-importData("/home/data_new.csv") >indata[1:5,4] [1] 0930 1601 1006 1032 1020 I tried the following R code: > indata<-read.csv("/home/data_new.csv") > indata[1:5,4] [1] 930 1601 1006 1032 1020 I'd like the first one to be 0930, too. Thanks in advance, Betty [[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-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] Finding Largest(or smallest) values
There are probably better ways but cant you subset each parameter? So create new variables for parameter 1, 2, ... and look at the summary data for those which will include a min and max for all variables. Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of alphaace Sent: Sunday, November 15, 2009 8:54 AM To: r-help@r-project.org Subject: [R] Finding Largest(or smallest) values Hi, I am trying to find a model of best fit, with 8 parameters. As such, I have created a table with 2^8=256 rows with every variable either in or out of the model(denoted by 1 or 0), and for each row, I have computed the Adjusted R^2, AIC, CP and Press. I know I can use the leaps package to find the best model (for every number of parameters n=1...8) for the Adjusted R2 and CP, but not for AIC and PRESS. I was wondering, if anyone has any code to say find the minimum press when the model has 1 parameter, 2 parameters, 3 parameters, etc... I have attached a copy of my table below for reference. Thank you for your help! > DF P X1 X2 X3 X4 X5 X6 X7 X8 Adjusted R2 AICCP PRESS 1 0 0 0 0 0 0 0 0 0 0.00 0.99464282 14.367679 95.01075 2 1 1 0 0 0 0 0 0 0 0.0246074998 -0.36362381 12.634643 93.70900 3 1 0 1 0 0 0 0 0 0 0.0382916889 -1.69172730 11.194739 92.46010 4 1 0 0 1 0 0 0 0 0 -0.0005184148 2.02713507 15.278491 96.11336 5 1 0 0 0 1 0 0 0 0 -0.002134 2.24957370 15.527913 96.38092 6 1 0 0 0 0 1 0 0 0 0.0272855281 -0.62206426 12.352850 92.64962 7 1 0 0 0 0 0 1 0 0 0.0111851503 0.92108831 14.046995 94.47172 8 1 0 0 0 0 0 0 1 0 0.0020990063 1.78090275 15.003075 94.60974 9 1 0 0 0 0 0 0 0 1 -0.0108209410 2.99012118 16.362563 97.09546 10 2 1 1 0 0 0 0 0 0 0.0810965349 -4.99889125 7.639659 89.49671 11 2 1 0 1 0 0 0 0 0 0.0266267059 0.41424802 13.308890 94.64288 12 2 0 1 1 0 0 0 0 0 0.0315413664 -0.06156976 12.797371 94.04593 13 2 1 0 0 1 0 0 0 0 0.0145736386 1.57108162 14.563375 95.37943 14 2 0 1 0 1 0 0 0 0 0.0479608482 -1.66893313 11.088428 92.39152 15 2 0 0 1 1 0 0 0 0 0.0005123888 2.90290718 16.026873 97.24004 16 2 1 0 0 0 1 0 0 0 0.0541222887 -2.27926275 10.447144 91.16842 17 2 0 1 0 0 1 0 0 0 0.0754976703 -4.42788850 8.222390 88.96712 18 2 0 0 1 0 1 0 0 0 0.0241535771 0.65277858 13.566293 93.96203 19 2 0 0 0 1 1 0 0 0 0.0275121981 0.32869589 13.216727 93.77620 20 2 1 0 0 0 0 1 0 0 0.0245589269 0.61372449 13.524104 94.06972 21 2 0 1 0 0 0 1 0 0 0.0622492592 -3.09039933 9.601287 90.89229 22 2 0 0 1 0 0 1 0 0 0.0085444331 2.14445635 15.190896 95.73424 23 2 0 0 0 1 0 1 0 0 0.0089907346 2.10213293 15.15 95.79122 24 2 0 0 0 0 1 1 0 0 0.0407860378 -0.96318114 11.835183 91.76667 25 2 1 0 0 0 0 0 1 0 0.0244877014 0.62058800 13.531518 93.36514 26 2 0 1 0 0 0 0 1 0 0.0407457114 -0.95922936 11.839381 92.16665 27 2 0 0 1 0 0 0 1 0 -0.0047937805 3.40062281 16.579140 96.5 28 2 0 0 0 1 0 0 1 0 0.0020858488 2.75480952 15.863107 95.82804 29 2 0 0 0 0 1 0 1 0 0.0248637496 0.58434515 13.492378 92.73311 30 2 0 0 0 0 0 1 1 0 0.0171446547 1.32551143 14.295783 93.74595 31 2 1 0 0 0 0 0 0 1 0.0138889013 1.63637615 14.634643 95.78017 32 2 0 1 0 0 0 0 0 1 0.0277245197 0.30817080 13.194629 94.26947 33 2 0 0 1 0 0 0 0 1 -0.0115063328 4.02650409 17.277784 98.26103 34 2 0 0 0 1 0 0 0 1 -0.0130170902 4.16679510 17.435024 98.57288 35 2 0 0 0 0 1 0 0 1 0.0193924225 1.11028937 14.061835 94.52438 36 2 0 0 0 0 0 1 0 1 0.0004693207 2.90695757 16.031355 96.66280 37 2 0 0 0 0 0 0 1 1 -0.0087026647 3.76559547 16.985978 96.73581 38 3 1 1 1 0 0 0 0 0 0.0754624308 -3.46299014 9.168628 90.98724 39 3 1 1 0 1 0 0 0 0 0.0761667614 -3.53462845 9.096127 90.47049 40 3 1 0 1 1 0 0 0 0 0.0179377080 2.21094883 15.090020 96.18373 41 3 0 1 1 1 0 0 0 0 0.0443170822 -0.34853563 12.374620 93.90532 42 3 1 1 0 0 1 0 0 0 0.1233192905 -8.45916839 4.242412 85.48181 43 3 1 0 1 0 1 0 0 0 0.0532048878 -1.22682152 11.459741 92.37654 44 3 0 1 1 0 1 0 0 0 0.0668617200 -2.59257716 10.053955 90.62446 45 3 1 0 0 1 1 0 0 0 0.0452547720 -0.44081112 12.278098 92.71992 46 3 0 1 0 1 1 0 0 0 0.0924857470 -5.20992520 7.416308 88.22170 47 3 0 0 1 1 1 0 0 0 0.0281772097 1.22570975 14.036002 94.88753 48 3 1 1 0 0 0 1 0 0 0.0890014298 -4.84971194 7.774972 89.34392 49 3 1 0 1
[R] Hmisc and Lattice question on gridlines
I have been using lattice xyplot and am quite pleased, and I can use the type=c("b","g") to have it print gridlines into the page, yet if I want to have a line plot with points on it, how do I get the xYplot to print gridlines (I use Hmisc xYplot because of its bands method which allows plotting of confidence intervals). Any suggestions? I have looked at the panel functions but when I try it I get the gridlines but my data is gone. So a simple example is below. I want to create the reference lines in the lattice plot in the xYplot from Hmisc so I can keep the confidence intervals filled. x<-seq(1,10,1) y<-seq(1,10,1) ci<-y*.10 ciupper<-y+ci cilower<-y-ci xyplot(y~x, type=c("b","g"),plot.points = TRUE)#using lattice xYplot(Cbind(y,cilower,ciupper)~x,col.fill="grey",plot.points = TRUE,type=c("b"),method="filled bands")#using Hmisc JOE [[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] Do you keep an archive of "useful" R code? and if so - how?
I accidentally sent this directly to the author and didn't reply to the whole list, I am sorry, I need to remember to hit reply all instead of reply to the R help list, heres my message: I keep a separate R file of code I commonly use but more generic. So if I am making contingency tables I say: ftable(category, category[top]) or if I am wanting to subset data: subset2$X5<-recode(subset2$X5, "6:10=1:5") things like that, generic code that I can refer to and include my variables in as necessary (as you can tell the "top" mark I made in ftable isn't in the code but reminds me how the table structures itself. Since I am a newbie at R I am still keeping notes, I do this for importing things, also graphics: xyplot(value~X1,data=subset1,groups=factor(X2), type=c("b","g"),ylim=c(0,1),xlim=c(1,5),lwd=1,cex = 1, plot.points = TRUE,auto.key = list(points = TRUE,lines = TRUE, space = "inside"), label.curves=FALSE,xlab = "x axis title", ylab = " y axis title ") so it just lets me organize my codes on my local system. R wiki is ok, but will be much better as people expand it, I am sure very soon it will grow exponentially as a good resource. (as you can tell some of the code I save includes old variable names instead of neutral ones, but easy enough to change). Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tal Galili Sent: Sunday, November 22, 2009 10:31 AM To: Marc Schwartz Cc: r-help@r-project.org; Barry Rowlingson; jeff.la...@noaa.gov Subject: Re: [R] Do you keep an archive of "useful" R code? and if so - how? Marc and Barry, many thanks for your detailed answers. Marc - I thank you for the links and ideas. Thanks to your advice I will look more into SVN in the future, although it sounds on the surface to require some learning curve, so It could take me some time to start using it. Barry - I am actually a blog builder in my side profession, I already built myself a blog called: r-statistics.com On which I intend to put up good code I will come across. The problem with it though is that I don't see blogs as a good information management system. Since on a blog one is open to the public and doesn't want to leave half scribles of thoughts (which IS what ends up happening when managing snippets of code). Also, blogging is not build for easy hierarchical ordering. The idea of a wiki is more appealing. BTW - another suggestion I got was using MS onenote. Although it is not open source (which is my preference as well), I understood it offers a powerful solution. I hope more people will share how they manage their snippets of code. Best to all of you, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com/ (English) -- On Sun, Nov 22, 2009 at 8:09 PM, Marc Schwartz wrote: > Tal, > > I would still use Subversion. > > Think of Subversion as as an electronic filing system. You can organize > code into project trees, with sub-folders and so forth. > > As you come across code snippets that you want to save, copy them to a file > and commit the file to a project tree or sub-folder, based upon the domain > of functionality. Add related code snippets to the same domains. That way, > you have related code snippets in a common area, making recall easier. > > The advantage of using a VCS is that you can make trackable modifications > to the code over time, as your functional requirements change or as you > discover bugs, etc. to existing code. > > In terms of a GUI, for Windows, it seems that most use Tortoise SVN: > > http://tortoisesvn.net/ > > There are cross-platform GUIs such as RapidSVN ( > http://rapidsvn.tigris.org/), but it all depends upon personal > preferences. More links here: > > http://subversion.tigris.org/links.html#all-clients > > There are also Subversion extensions for editors, such as Emacs, like > psvn.el (http://www.xsteve.at/prg/vc_svn/) which enable a blending of > functionality into environments that you may already be using, such as ESS. > > Last but not least, there are also commercial variants of Subversion > clients, which of course have a cost associated with them. These are also > listed on the clients link above. > > An alternative would be to create a local wiki, the implementation details, > as with a Subversion repo, would be dependent upon wheth
Re: [R] reshape question
What about the melt function in reshape package? EX: > x=sample(1:100,20,replace=T) > x [1] 48 94 32 96 81 99 10 64 64 94 57 60 16 64 32 76 63 1 64 8 > y=sample(1:100,20,replace=T) > y [1] 73 78 82 43 58 85 74 64 73 41 45 38 63 36 44 74 7 88 91 1 > xy=cbind(x,y) > melt(xy) X1 X2 value 1 1 x48 2 2 x94 3 3 x32 4 4 x96 5 5 x81 6 6 x99 7 7 x10 8 8 x64 9 9 x64 10 10 x94 11 11 x57 12 12 x60 13 13 x16 14 14 x64 15 15 x32 16 16 x76 17 17 x63 18 18 x 1 19 19 x64 20 20 x 8 21 1 y73 22 2 y78 23 3 y82 24 4 y43 25 5 y58 26 6 y85 27 7 y74 28 8 y64 29 9 y73 30 10 y41 31 11 y45 32 12 y38 33 13 y63 34 14 y36 35 15 y44 36 16 y74 37 17 y 7 38 18 y88 39 19 y91 40 20 y 1 > Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Tuesday, November 24, 2009 6:43 PM To: AC Del Re Cc: r-help@r-project.org Subject: Re: [R] reshape question On Nov 24, 2009, at 8:33 PM, AC Del Re wrote: > Hi All, > > I am wanting to convert a data.frame from a wide format to a long > format > (with >1 variable) and am having difficulties. Any help is > appreciated! > > #current wide format >> head(data.out2) > id rater.1 n.1 rater.2 n.2 rater.3 n.3 rater.4 n.4 > 11 11 0.118 79NA NANA NANA NA > 114 114 0.2478709 113NA NANA NANA NA > 12 12 0.3130655 54 0.3668242 54NA NANA NA > 121 121 0.240 331NA NANA NANA NA > 122 122 0.3004164 25 0.1046278 25 0.2424871 25 0.2796937 25 > 125 125 0.1634865 190NA NANA NANA NA > > #This is close but I would like the 'n' column to remain and for the > '.1' to > drop off I don't really understand what you want and the example solution throws away quite a lot of data, so consider this alternative: data.out2 <- read.table(textConnection("id rater.1 n.1 rater.2 n. 2 rater.3 n.3 rater.4 n.4 11 11 0.118 79NA NANA NANA NA 114 114 0.2478709 113NA NANA NANA NA 12 12 0.3130655 54 0.3668242 54NA NANA NA 121 121 0.240 331NA NANA NANA NA 122 122 0.3004164 25 0.1046278 25 0.2424871 25 0.2796937 25 125 125 0.1634865 190NA NANA NANA NA"), header=T, stringsAsFactors=F) data.frame(id= data.out2$id, rater=stack(data.out2[,grep("rater", names(data.out2))]), n= stack(data.out2[,grep("n", names(data.out2))]) ) data.out2.id rater.values rater.ind n.values n.ind 1110.118 rater.1 79 n.1 2 1140.2478709 rater.1 113 n.1 3120.3130655 rater.1 54 n.1 4 1210.240 rater.1 331 n.1 5 1220.3004164 rater.1 25 n.1 6 1250.1634865 rater.1 190 n.1 711 NA rater.2 NA n.2 8 114 NA rater.2 NA n.2 9120.3668242 rater.2 54 n.2 10 121 NA rater.2 NA n.2 11 1220.1046278 rater.2 25 n.2 12 125 NA rater.2 NA n.2 13 11 NA rater.3 NA n.3 14 114 NA rater.3 NA n.3 15 12 NA rater.3 NA n.3 16 121 NA rater.3 NA n.3 17 1220.2424871 rater.3 25 n.3 18 125 NA rater.3 NA n.3 19 11 NA rater.4 NA n.4 20 114 NA rater.4 NA n.4 21 12 NA rater.4 NA n.4 22 121 NA rater.4 NA n.4 23 1220.2796937 rater.4 25 n.4 24 125 NA rater.4 NA n.4 You can take what you like from what I would consider a version that has no loss of the original information. > >> data.out3<-reshape(data.out2,varying=list(names(data.out2)[-1]), > + idvar='id',direction='long') >> head(data.out3) > id time rater.1 > 11.1 111 0.118 > 114.1 1141 0.2478709 > 12.1 121 0.3130655 > 121.1 1211 0.240 > 122.1 1221 0.3004164 > 125.1 1251 0.1634865 > > Ideally I would like the columns to be
[R] layers in xYplot of Hmisc
In the "filled bands" part of xYplot of the Hmisc package, is there a way to have multiple bands with multiple lines? or does it just allow one for now? So I had an example bit ago had a made up line and CI, now if I wanted to make a second line with a CI filled in can I put them on the same plot? x<-seq(1,10,1) y<-seq(1,10,1) ci<-y*.10 ciupper<-y+ci cilower<-y-ci xYplot(Cbind(y,cilower,ciupper)~x, method="filled bands", col.fill="light grey", type=c("b")) x2<-seq(1,5,.5) y2<-seq(1,5,.5) ci2<-y2*.10 ciupper2<-y2+ci2 cilower2<-y2-ci2 xYplot(Cbind(y2,cilower2,ciupper2)~x2, method="filled bands",col.fill="light grey", type=c("b")) --- Joe King, M.A. Ph.D. Student University of Washington - Seattle 206-913-2912 j...@joepking.com --- "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt [[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] Create sequence given start and end vector
Also what about c(seq(1,4,1),seq(10,15,1),seq(20,27,1)) Joe King j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jorge Ivan Velez Sent: Saturday, December 12, 2009 1:43 PM To: Kevin Ummel Cc: r-help@r-project.org Subject: Re: [R] Create sequence given start and end vector Hi Kevin, Here is a suggestion using mapply(): start <- c(1,10,20) end <- c(4,15,27) do.call(c, mapply( seq, start, end)) See ?mapply and ?do.call for more information. HTH, Jorge On Sat, Dec 12, 2009 at 2:27 PM, Kevin Ummel <> wrote: > How can I create the following without the 'for' loop? > > start=c(1,10,20) > > end=c(4,15,27) > > out=c() > > for (i in 1:length(start)) { >out=c(out,start[i]:end[i]) >} > out > [1] 1 2 3 4 10 11 12 13 14 15 20 21 22 23 24 25 26 27 > > I know there must be an easier (and, hopefully, faster) way. > > Many thanks in advance, > Kevin Ummel > > Central European University > Department of Environmental Science and Policy > > __ > 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-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] Hmisc filled bands colors
Hi all, i am still using the Hmisc package and I like the filled bands part, is there a way though to have different groups have different color of bands, maybe a lighter version of the color of the line that is used? --- Joe King, M.A. Ph.D. Student University of Washington - Seattle 206-913-2912 j...@joepking.com --- "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt [[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] subtitle in Hmisc xYplot
Ok so I am trying to add a subtitle to my xYplot using Hmisc and I have some dummy code of x<-seq(1,10,1) y<-rev(seq(1,10,1)) ci<-y*.10 ciupper<-y+ci cilower<-y-ci this code works fine: xYplot(Cbind(y,ciupper,cilower)~x, type=c("b"),plot.points = TRUE, method='filled bands', main='main title') but when I add sub=. at the end and use this xYplot(Cbind(y,ciupper,cilower)~x, type=c("b"),plot.points = TRUE, method='filled bands', main='main title', sub='subtitle') I get an error saying subscript out of bounds, any help? --- Joe King, M.A. Ph.D. Student University of Washington - Seattle 206-913-2912 j...@joepking.com --- "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt [[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] "Object is not a matrix" Error
When you imported did you not import the headers? Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jim holtman Sent: Sunday, December 20, 2009 3:11 PM To: John Paul Telthorst Cc: r-help@r-project.org Subject: Re: [R] "Object is not a matrix" Error Where is the object 'write'? SHouldn't you be using: lm(visits ~ (day.f)) On Sun, Dec 20, 2009 at 5:59 PM, John Paul Telthorst wrote: > I'm trying to follow this guide here: > http://www.ats.ucla.edu/stat/r/modules/dummy_vars.htm > > In which I'm creating categorical variables using the factor function. > > I am able to go through the example listed above and have everything work, > however, when I try to input my own numbers, I get an error. I input the > following: > > > > hits = read.csv(file.choose()) > > > attach(hits) > > > day.f <- factor(day) > > > lm(write ~ (day.f)) > > lm(write ~ (day.f)) > > Error in model.frame.default(formula = write ~ (day.f), drop.unused.levels > = > > TRUE) : > > object is not a matrix > > > > So I import "hits = read.csv(file.choose())" a .csv file, which has the > columns "visits" and "day" where "visits" is the number of hits to a > website, and "day" is a number 1-7, for example 1 corresponds to Sunday and > 7 corresponds to Saturday. I understand that the day variable needs to be > a > categorical variable, and I'm trying to use the factor function to do this. > I would like to be able to run a regression that will correlate the day > with the number of hits. > > Any help would be much appreciated. > >[[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<http://www.r-project.org/posting -guide.html> > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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-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] Signif. codes
There will always be uncertainty in your estimates so you don't have 0 percent chance of being wrong, but remember that's your intercept, your regressors are not significant. Although you can say it is less than ..05, I mean if its significant at .001 (or something like that), that's less than .05, so its not unethical to say p < .05, but it sounds like you need to understand the regression model a little better. Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of John Paul Telthorst Sent: Sunday, December 20, 2009 10:13 PM To: r-help@r-project.org Subject: [R] Signif. codes My question is about the "Signif. codes" and the p-value, specifically, the output when I run summary(nameofregression.lm) So you get this little key: Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 And on a regression I ran, next to the intercept data, I get '***' Coefficients: > > Estimate Std. Error t value Pr(>|t|) > > (Intercept) 7.956520.59993 13.262 <2e-16 *** > > day.f2 -0.043480.84843 -0.0510.959 > > day.f3 -0.130430.84843 -0.1540.878 > > day.f4 -0.217390.84843 -0.2560.798 > > day.f5 0.021740.84843 0.0260.980 > > day.f6 -0.152170.84843 -0.1790.858 > > day.f7 0.149860.84390 0.1780.859 > > Does this mean that these numbers have a 0% chance of being wrong? Is there a way to change this to the .05 level of significance? Thanks, John [[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] Signif. codes
No, so the probability means that's the probability of getting that data by chance, so a p-value of .9997 means there is a .9997 probability that the data could be acquired by chance. This is a very simplistic view and you should study the regression model better. Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt From: John Paul Telthorst [mailto:jpteltho...@gmail.com] Sent: Sunday, December 20, 2009 10:36 PM To: Joe King Subject: Re: [R] Signif. codes Thanks for the reply, I definitely do need to understand the regression model better. I got a p-value of .9997, so that would be > .05? I guess I'm confused about the significance part you talked about. John On Mon, Dec 21, 2009 at 12:27 AM, Joe King wrote: There will always be uncertainty in your estimates so you don't have 0 percent chance of being wrong, but remember that's your intercept, your regressors are not significant. Although you can say it is less than ..05, I mean if its significant at .001 (or something like that), that's less than .05, so its not unethical to say p < .05, but it sounds like you need to understand the regression model a little better. Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of John Paul Telthorst Sent: Sunday, December 20, 2009 10:13 PM To: r-help@r-project.org Subject: [R] Signif. codes My question is about the "Signif. codes" and the p-value, specifically, the output when I run summary(nameofregression.lm) So you get this little key: Signif. codes: 0 0.001 0.01 0.05 0.1 And on a regression I ran, next to the intercept data, I get '***' Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 7.956520.59993 13.262 <2e-16 *** > day.f2 -0.043480.84843 -0.0510.959 > day.f3 -0.130430.84843 -0.1540.878 > day.f4 -0.21739 0.84843 -0.2560.798 > day.f5 0.021740.84843 0.0260.980 > day.f6 -0.152170.84843 -0.1790.858 > day.f7 0.14986 0.84390 0.1780.859 Does this mean that these numbers have a 0% chance of being wrong? Is there a way to change this to the .05 level of significance? Thanks, John [[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. -- John Telthorst, MHRIR University of Illinois Alumnus [[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] Is SEM package of R suitable for sem analysis
I am going to take SEM this next quarter in my doctoral program. My suggestion is to use the program your professor suggests and try to re-create your models in R using the SEM package. We are not going to use AMOS though we use EQS, and another prof on campus who teaches it in a different department uses LISREL, so since SEM hasn't been implemented in most commercial software and you need specialty software for it, it may be best to know several different software programs if you want to do SEM type work. I do have a feeling since R is growing so rapidly it wont take time for people in the community to create packages or develop existing packages equal to or greater than commercial software! LONG LIVE R :) Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Reeyarn_???_10928113 Sent: Saturday, December 26, 2009 3:50 AM To: R-help@r-project.org Subject: [R] Is SEM package of R suitable for sem analysis Dears, I'm a college student and In doing my statistics homework. I use R with SEM package as my tool for sem analysis, but my teacher told me AMOS is more suitable for such analysis. Could someone help tell me whether it is true that some commercial software is better accepted in academic fields? Sorry if I should not post such topics here. -- Best Regards, Reeyarn T. Lee Accounting Dept, Guanghua School of Management, Peking University, Beijing, P.R. China __ 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.
Re: [R] Is SEM package of R suitable for sem analysis
Your welcome, I wanted to say I agree with Bruno that the comparative software is very expensive, even more prohibitively so for students and even though MPlus is good I think R will catch up rapidly and even overtake those as people who use these modeling techniques become more integrated into the R community. Joe King 206-913-2912 j...@joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Reeyarn_???_10928113 Sent: Saturday, December 26, 2009 6:27 PM To: R-help@r-project.org Subject: Re: [R] Is SEM package of R suitable for sem analysis Dear Bruno and Joe, Thanks for advising! Reeyarn On Sat, Dec 26, 2009 at 9:32 PM, Bruno Falissard wrote: > A few years ago it could have been true, but now the package has improved > (especially with the bootstrap procedure). > At the moment there is no argument to recommend AMOS. On Sun, Dec 27, 2009 at 12:30 AM, Joe King wrote: > I am going to take SEM this next quarter in my doctoral program. My > suggestion is to use the program your professor suggests and try to > re-create your models in R using the SEM package. __ 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] anova help
Hi all, I am trying to run a two factor anova, but one of the factors is a random factor, now I am also running in SPSS and it seems its dividing by the wrong term to get the appropriate F term. here is my data. In SPSS the F scores about double the ones in R, how can I specify one of my factors as a random factor or change it to where it does the right model fitting? I am using the lm command instead of glm. I am new to R so this might seem basic. Joe King, M.A. <mailto:j...@joepking.com> j...@joepking.com "Never give in, never give in, never; never; never; never - in nothing, great or small, large or petty - never give in except to convictions of honor and good sense" - Winston Churchill "You have enemies? Good. That means you've stood up for something, sometime in your life." - Winston Churchill [[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] anova help
Ok well heres my data, with the second variable (B variable) being the random variable and the other fixed. Although the F values are about half of what SPSS puts out. My code is anova(lm(dependentrandom~typemusic+typemusic*musicselection)) This is just dummy data for a class but I am trying to use the data I am running in SPSS to learn R. I am also in an R class but we are not going to learn ANOVA. Joe King, M.A. <mailto:j...@joepking.com> j...@joepking.com "Never give in, never give in, never; never; never; never - in nothing, great or small, large or petty - never give in except to convictions of honor and good sense" - Winston Churchill "You have enemies? Good. That means you've stood up for something, sometime in your life." - Winston Churchill From: Tal Galili [mailto:tal.gal...@gmail.com] Sent: Sunday, February 15, 2009 10:25 AM To: Joe King Cc: r-help@r-project.org Subject: Re: [R] anova help Hi Joe, you might want to have a look at the nlme package with the lme command. Another option is the more advanced lmer package. Lastly, you could have a look at the ?aov command, and notice the option of using the +Error() term (but that would only work for balanced design cases, so I've heard, so be aware) Tal On Sat, Feb 14, 2009 at 8:46 PM, Joe King wrote: Hi all, I am trying to run a two factor anova, but one of the factors is a random factor, now I am also running in SPSS and it seems its dividing by the wrong term to get the appropriate F term. here is my data. In SPSS the F scores about double the ones in R, how can I specify one of my factors as a random factor or change it to where it does the right model fitting? I am using the lm command instead of glm. I am new to R so this might seem basic. Joe King, M.A. <mailto:j...@joepking.com> j...@joepking.com "Never give in, never give in, never; never; never; never - in nothing, great or small, large or petty - never give in except to convictions of honor and good sense" - Winston Churchill "You have enemies? Good. That means you've stood up for something, sometime in your life." - Winston Churchill [[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. -- -- My contact information: Tal Galili Phone number: 972-50-3373767 FaceBook: Tal Galili My Blogs: www.talgalili.com www.biostatistics.co.il __ 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.