[R] comparing linear models

2012-04-18 Thread JesperHybel
I wanted to do an F-test to compare model L2 with L3 assuming heteroskedasticity. The variable KONK2 only has three levels and are for that reason replaced by dummyvariables KONKD1 and KONKD2 in L3. Hence making L4 equivalent to L2. L2-lm(PRMRES ~ factor(NYPR) + KONK2 + OMS + factor(NYPR)*OMS )

Re: [R] Is there a way to find all roots of a polynomial equation in R?

2012-04-18 Thread JesperHybel
Is there a way to find all roots of a polynomial equation? Lets say x^5+a*x^4+b*x^3+c*x^2+d*x+e=0 how to find its all roots? The package rootSolve might proove interesting __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help

[R] Using objectname in function

2010-08-18 Thread JesperHybel
Is there anyway I can convert a vectors objectname to a string to be used in fx: Monkey-c(0,0,0,1,1,1) Wax-c(1,0,1,0,1,0) f-function(x,y){ table(x,y) } f(Monkey,Wax) so that the printout is not y x 0 1 0 1 2 1 2 1 but Wax Monkey 0 1 0 1 2 1 2 1 -- View

Re: [R] ifelse command

2010-08-18 Thread JesperHybel
Or try: datbig-numeric(1000) for (i in 1:1000){ datbig[i] - mean(sample(1:6, 1000, prob = c(1, 1, 2, 3, 2, 1)/10, replace = TRUE)) hist(datbig,breaks=FD) -- View this message in context: http://r.789695.n4.nabble.com/ifelse-command-tp2329538p2329711.html Sent from the R help mailing list

Re: [R] ifelse command

2010-08-18 Thread JesperHybel
sorry missed an } datbig-numeric(1000) for (i in 1:1000){ datbig[i] - mean(sample(1:6, 1000, prob = c(1, 1, 2, 3, 2, 1)/10, replace = TRUE)) hist(datbig,breaks=FD) } -- View this message in context: http://r.789695.n4.nabble.com/ifelse-command-tp2329538p2329717.html Sent from the R help

[R] Plotproblem, histogram, y-axis label?

2010-08-17 Thread JesperHybel
How can I control label on y-axis? Specifically how high relative to the y-axis it is plotted? At the moment I am using mtext appearing in the function quotet below. The function is applied to a dataframe and plots histograms for all numerical variables of the frame generating several

Re: [R] Learning ANOVA

2010-08-14 Thread JesperHybel
how to plot 4 graphs simultaneously? Depends on what graphs were talking about: A Side-by-side boxplot containing fx 4 boxplots can be generated by a single plot() command. However often you use a primary command that activivates the plot window and plots one graph, then afterwards you use

Re: [R] How to perform a substitution in a loop?

2010-08-14 Thread JesperHybel
You need {} for (i in 1:500){ ...commands...} Like: x-rep(c(0.8,1.2),250) for (i in 1:500) { if (x[i]1) x[i]=1 } BR JEsper -- View this message in context: http://r.789695.n4.nabble.com/How-to-perform-a-substitution-in-a-loop-tp2325048p2325073.html Sent from the R help mailing

Re: [R] Linear regression on several groups

2010-08-13 Thread JesperHybel
Example is spot on - sr for not providing one myself. The results you calculate are what I'm looking for. Would like a function F where I could type: F(weight ~ Time, data = ChickWeight, SOME ARGUMENT = Diet)) Resulting in for (i in 1:4){ print( lm(weight ~ Time, data = ChickWeight, subset =

Re: [R] Learning ANOVA

2010-08-13 Thread JesperHybel
If you're trying to follow the youtube video you have a typing mistake here: InsectSprays.aov -(test01$count ~ test01$spray) I think this should be: InsectSprays.aov -aov(test01$count ~ test01$spray) youre missing the functioncall aov on the right hand side of the assignment operator '-'.

Re: [R] merge function in R?

2010-08-13 Thread JesperHybel
I think it would be helpful if you could clarify youre question - do you want distinct sets - maybe use unique() but why (5,20) when its (5,10) in the row in youre example? What criteria do you want the function to select the sets by and what kind of output do you need? Maybe it's just me

[R] Linear regression on several groups

2010-08-12 Thread JesperHybel
I have a simple dataset of a numerical dependent Y, a numerical independent X and a categorial variable Z with three levels. I want to do linear regression Y~X for each level of Z. How can I do this in a single command that is without using lm() applied three isolated times? -- View this message

Re: [R] Creating vectors

2010-08-12 Thread JesperHybel
You can use following scriptI think #create a vector of random numbers on which to test script v-sample(1:3,size=90,replace=TRUE) #creates two matrixes out of vector v which can be assigned to M to test script M2-matrix(v,ncol=2) M3-matrix(v,ncol=3) M- #Assign you're matrix or a