Re: [R] "Within" model in plm package: is the reported R-squared correct?

2018-02-20 Thread Bert Gunter
Generally speaking, statistical questions are O/T here, but sometimes they intersect with on-topic R programming issues and do get responses. So if you do not get a response here, try a statistics forum, like stats.stackexchange.com . Cheers, Bert Bert Gunter "The trouble with having an open

[R] "Within" model in plm package: is the reported R-squared correct?

2018-02-20 Thread Dung Nguyen
Hi everyone, I am doing panel data analysis using the 'plm' package. However, I have noticed that the plm() function reports a different value of R-squared from the R-squared of the lm() function with time-demeaned data. To be clear, I have tried to compute the within model both manually (run an O

Re: [R] Within ID variable delete all rows after reaching a specific value

2014-04-26 Thread arun
Hi, You may also try: set.seed(425) ##your code tmp <- data.frame( # tmp1 <- tmp str(tmp1) #'data.frame':    1000 obs. of  3 variables: # $ X1: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ... # $ X2: Factor w/ 127 levels "1","10","100",..: 1 1 1 1 1 1 1 1 2 2 ... # $ X3: Factor w/

Re: [R] Within ID variable delete all rows after reaching a specific value

2014-04-26 Thread Jeff Newmiller
Jennifer: a) Don't post in HTML... read the Posting Guide. b) Don't make data frames by first making matrices... you rarely create what you think you are creating. In your case, your code creates a bunch of factor columns... use the str() function to verify that your data are sensible before

Re: [R] Within ID variable delete all rows after reaching a specific value

2014-04-25 Thread Jim Lemon
On 04/26/2014 12:42 PM, Jennifer Sabatier wrote: So, I know that's a confusing Subject header. Here's similar data: tmp<- data.frame(matrix( c(rbinom(1000, 1, .03), array(1:127, c(1000,1)), array(format(seq(ISOdate(

[R] Within ID variable delete all rows after reaching a specific value

2014-04-25 Thread Jennifer Sabatier
So, I know that's a confusing Subject header. Here's similar data: tmp <- data.frame(matrix( c(rbinom(1000, 1, .03), array(1:127, c(1000,1)), array(format(seq(ISOdate(1990,1,1), by='month', length=56), format='%d.%m.%Y')

[R] “Within is working or not in loop”

2012-04-10 Thread Bharat Warule
“Within is working or not in loop” for(j in 1:10){ card_bal <- as.numeric(segment_cuts$card_bal[[j]]) insurance_bal <- as.numeric(segment_cuts$insurance_bal[[j]]) data$segment_rank <- within(data,segment_rank[ data$Total_Balance >= total_bal & data$Insurance_Balance >= insurance_bal] <-

Re: [R] How does one start R within Emacs/ESS with root privileges?

2011-09-09 Thread Karl Brand
e: Esteemed UseRs and DevelopeRs, Apologies if this question belongs else where, but it does concern R's package installation/maintenance. How does one start R within Emacs/ESS with root privileges? I tried without success: M-x sudo R Why i'm motivated to do so: It seems logical

Re: [R] How does one start R within Emacs/ESS with root privileges?

2011-09-07 Thread Spencer Graves
appropriate forum at: ess-h...@stat.math.ethz.ch Karl On 2011-09-07 11:02, Paul Hiemstra wrote: On 09/07/2011 08:54 AM, Karl Brand wrote: Esteemed UseRs and DevelopeRs, Apologies if this question belongs else where, but it does concern R's package installation/maintenance. How does

Re: [R] How does one start R within Emacs/ESS with root privileges?

2011-09-07 Thread Karl Brand
.ch Karl On 2011-09-07 11:02, Paul Hiemstra wrote: On 09/07/2011 08:54 AM, Karl Brand wrote: Esteemed UseRs and DevelopeRs, Apologies if this question belongs else where, but it does concern R's package installation/maintenance. How does one start R within Emacs/ESS with root privileg

Re: [R] How does one start R within Emacs/ESS with root privileges?

2011-09-07 Thread Paul Hiemstra
On 09/07/2011 08:54 AM, Karl Brand wrote: > Esteemed UseRs and DevelopeRs, > > Apologies if this question belongs else where, but it does concern R's > package installation/maintenance. > > How does one start R within Emacs/ESS with root privileges? > > I tried with

[R] How does one start R within Emacs/ESS with root privileges?

2011-09-07 Thread Karl Brand
Esteemed UseRs and DevelopeRs, Apologies if this question belongs else where, but it does concern R's package installation/maintenance. How does one start R within Emacs/ESS with root privileges? I tried without success: > M-x sudo R Why i'm motivated to do so: It seems logi

Re: [R] within-groups variance and between-groups variance

2011-08-26 Thread S Ellison
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Coghlan, Avril > Sent: 25 August 2011 16:02 > To: r-help@r-project.org > Cc: Coghlan, Avril > Subject: [R] within-groups variance and between-groups varian

Re: [R] within-groups variance and between-groups variance

2011-08-25 Thread Daniel Malter
#Here is I think an easier way of coding all the components you need. #The within-group variances, you get with this function: apply(iris[,1:4],2,function(x) tapply(x,iris$Species,var)) #You can get what you computed by taking the column means. apply(apply(iris[,1:4],2,function(x) tapply(x,iri

[R] within-groups variance and between-groups variance

2011-08-25 Thread Coghlan, Avril
Hello, I have been looking for functions for calculating the within-groups variance and between-groups variance, for the case where you have several numerical variables describing samples from a number of groups. I didn't find such functions in R, so wrote my own versions myself (see below). I ca

Re: [R] within()

2011-05-19 Thread David Winsemius
On May 19, 2011, at 9:32 AM, Timothy Bates wrote: Likewise it would help reduce confusion when plot(~Source, data=Df) # works # but boxplot(~Source, data=Df) # Error in boxplot.formula(~Source, data = Df) : # 'formula' missing or incorrect The formula isn’t missing or illformed, it’s that bo

Re: [R] within()

2011-05-19 Thread Duncan Murdoch
On 19/05/2011 9:32 AM, Timothy Bates wrote: The most interesting thing in this thread for me was "within()" - that is what I want 99% of the time, but I had only ever heard of with() A real boon! Thanks Bill V! The help for within gives this example for with(), which seems unnecessary, as glm

[R] within()

2011-05-19 Thread Timothy Bates
The most interesting thing in this thread for me was "within()" - that is what I want 99% of the time, but I had only ever heard of with() A real boon! Thanks Bill V! The help for within gives this example for with(), which seems unnecessary, as glm supports data= with(anorexia, { anorex.1

Re: [R] within group sequential subtraction

2011-03-10 Thread jim holtman
Try this: > data$diff <- ave(as.numeric(data$date_obs), data$group, FUN=function(x)c(NA, > diff(x))) > data group date_obs diff 1 IND1 1987-09-17 NA 2 IND1 1989-05-04 595 3 IND2 1997-04-30 NA 4 IND2 2008-11-03 4205 5 IND2 2009-05-08 186 6 IND3 1984-01-17 NA 7 IND4 1996-

Re: [R] within group sequential subtraction

2011-03-10 Thread Joshua Wiley
Dear Natalie, I am sure there are other ways, but one way you can do this is by applying diff() to each group using tapply() or by(). Because those return lists, if you want to add it back into your data frame, you can wrap the whole call in unlist(). Here is an example: dat <- structure(list(g

[R] within group sequential subtraction

2011-03-10 Thread natalie.vanzuydam
Hi Everyone, I would like to do sequential subtractions within a group so that I know the time between separate observations for a group of individuals. My data: data <- structure(list(group = c("IND1", "IND1", "IND2", "IND2", "IND2", "IND3", "IND4", "IND5", "IND6", "IND6"), date_obs = struc

Re: [R] Creating Boxpot with R within bash script

2011-02-27 Thread Joshua Wiley
Hi Greg, When you are running R from a script, you want to divert the output somewhere. Depending exactly how you run it, R may nicely push the text output to a file, but you should specify where you want the graphics to go yourself. For example: ## use the PDF graphics device pdf(file = "boxpl

[R] Creating Boxpot with R within bash script

2011-02-27 Thread Fishel, Greg
I will confess to being very wet behind the ears when it comes to scripting, so with that as a backdrop, here is my question. I can create a box and whisker plot without any problem from the command line, but incorporating that process into a bash script has proved problematic. Below is the port

[R] Execute commands in 'R' within PERL Program

2010-07-05 Thread chakri_amateur
t;Problem calling R from within perl script on Windows ..", from there I picked up the system command to call R from within PERL. Thanks barrry ! I am hoping that somebody from that thread could help me.. ! Thanks Chakri -- View this message in context: http://r.789695.n4.nabble.com/Exec

Re: [R] Within-group correlation confidence intervals

2009-09-20 Thread David Freedman
you should save your 3 variables into a new *dataframe* d<-mydata[,c("iq","education","achievement")] and then the command would be by(d,d$sex,function(df) cor.test(df$educ,df$achiev)) but you could also just use by(mydata,mydata$sex,function(df) cor.test(df$educ,df$achiev)) david freedman

[R] Within-group correlation confidence intervals

2009-09-18 Thread jlwoodard
I'm trying to obtain within-group correlations on a subset of variables. I first selected my variables using the following command: mydata$x<-mydata[c("iq","education","achievement")] I'd like to look at correlations among those variables separately for men and women. My gender variable in mydata

Re: [R] within: order of newly added variables

2009-09-02 Thread Duncan Murdoch
On 9/2/2009 1:31 PM, Peter Ehlers wrote: Heinrich, You could create your own function mywithin() by inserting a couple of rev()'s in within.data.frame(). In within.data.frame(), replace the two commented lines with those immediately following: mywithin <- function (data, expr, ...) { pare

Re: [R] within: order of newly added variables

2009-09-02 Thread Gabor Grothendieck
On Wed, Sep 2, 2009 at 9:27 AM, RINNER Heinrich wrote: > Dear R community, > > I am using function 'within' in R.2.9.1 to add variables to an existing > data.frame. This works wonderful, except for one minor point: The new > variables are added to the data in reverse order. > > For example: > x <

Re: [R] within: order of newly added variables

2009-09-02 Thread Peter Ehlers
Heinrich, You could create your own function mywithin() by inserting a couple of rev()'s in within.data.frame(). In within.data.frame(), replace the two commented lines with those immediately following: mywithin <- function (data, expr, ...) { parent <- parent.frame() #e <- evalq(enviro

Re: [R] within: order of newly added variables

2009-09-02 Thread Duncan Murdoch
On 9/2/2009 9:27 AM, RINNER Heinrich wrote: Dear R community, I am using function 'within' in R.2.9.1 to add variables to an existing data.frame. This works wonderful, except for one minor point: The new variables are added to the data in reverse order. For example: x <- data.frame(a = 1:3, b

Re: [R] within: order of newly added variables

2009-09-02 Thread Henrique Dallazuanna
Try this: transform(transform(x, c = a ^ 2, d = b ^2), e = c + d) On Wed, Sep 2, 2009 at 10:27 AM, RINNER Heinrich < heinrich.rin...@tirol.gv.at> wrote: > Dear R community, > > I am using function 'within' in R.2.9.1 to add variables to an existing > data.frame. This works wonderful, except for

[R] within: order of newly added variables

2009-09-02 Thread RINNER Heinrich
Dear R community, I am using function 'within' in R.2.9.1 to add variables to an existing data.frame. This works wonderful, except for one minor point: The new variables are added to the data in reverse order. For example: x <- data.frame(a = 1:3, b = 4:6) y <- within(x, { c = a^2 d =

Re: [R] Within factor & random factor

2009-08-29 Thread Juliet Hannah
Let's say that location defined a group, and observations may be more similar in a group. You could account for this similarity with the following model. model1 <-lme(X~CorP,random=~1|location,data=mydata,method="ML") This fits a random intercept model grouped by location. This would assume that

[R] Within factor & random factor

2009-08-26 Thread 細田弘吉
Hi, I am quite new to R and trying to analyze the following data. I have 28 controls and 25 patients. I measured X values of 4 different locations (A,B,C,D) in the brain image of each subject. And X ranges from 0 to 1. I think "control or patient" is a between subject factor and location is a wi

Re: [R] Within Subject ANOVA question

2009-06-01 Thread Peter Dalgaard
tsunhin wong wrote: Dear R users, I have copied for following table from an article on "Using confidence intervals in within-subject designs": Subject 1sec 2sec 5sec 1 10 13 13 12.00 2 6 8 8 7.33 3 11 14 14 13.00 4 22 23 25 23.33 5 16 18 20 18.00 6 15 17 17 16.33 7 1 1 4 2.00 8 12 15 17 14.67 9

Re: [R] Within Subject ANOVA question

2009-06-01 Thread Mike Lawrence
str() is again your friend. > str(asummary) List of 2 $ Error: subject :List of 1 ..$ :Classes ‘anova’ and 'data.frame':1 obs. of 5 variables: .. ..$ Df : num 9 .. ..$ Sum Sq : num 943 .. ..$ Mean Sq: num 105 .. ..$ F value: num NA .. ..$ Pr(>F) : num NA ..- at

Re: [R] Within Subject ANOVA question

2009-06-01 Thread tsunhin wong
As another follow-up related to aov, I want to extract values (Residual interaction mean square & interaction DF) from the results: asummary<-summary(aov.recall) The results are in a list() format with 3 lists, and contents within each list are without "names". I am not able to do something like i

Re: [R] Within Subject ANOVA question

2009-06-01 Thread Mike Lawrence
On Mon, Jun 1, 2009 at 7:50 PM, tsunhin wong wrote: > But I have some follow-up questions: > 1. In aov, why IVs (subject & condition) cannot be in number format? Put simply, because that's the only way to obtain the values you observe in the paper you're reading. :Op Factorizing tells the ANOVA

Re: [R] Within Subject ANOVA question

2009-06-01 Thread Mike Lawrence
Although you factorized subject and condition when you created them as separate objects, this didn't survive cbind() then as.data.frame(), thus > example<-data.frame(cbind(subject,condition,recall)) > str(example) 'data.frame': 30 obs. of 3 variables: $ subject : int 1 2 3 4 5 6 7 8 9 10 ...

Re: [R] Within Subject ANOVA question

2009-06-01 Thread tsunhin wong
I have reformatted the data input in the following ways, and I get the normal results: >subject<-factor(c("s1","s2","s3","s4","s5","s6","s7","s8","s9","s10","s1","s2","s3","s4","s5","s6","s7","s8","s9","s10","s1","s2","s3","s4","s5","s6","s7","s8","s9","s10")) >condition<-factor(c("c1","c1","c1","c

[R] Within Subject ANOVA question

2009-06-01 Thread tsunhin wong
Dear R users, I have copied for following table from an article on "Using confidence intervals in within-subject designs": Subject 1sec 2sec 5sec 1 10 13 13 12.00 2 6 8 8 7.33 3 11 14 14 13.00 4 22 23 25 23.33 5 16 18 20 18.00 6 15 17 17 16.33 7 1 1 4 2.00 8 12 15 17 14.67 9 9 12 12 11.00 10 8 9

[R] Within and Between matrix

2007-12-21 Thread cgenolin
Hi the list... I am working on cluster analysis, more precisely on Calinski and Harabasz criterion ( C(g)=Trace(between)/Trace(Within)*(n-g)/(g-1)) ) Is there a package for calculating within and between matrix? Morever, when we are using matrix with missing value, how do they handle it? On a mo

[R] Problem with R(D) Com and R within Excel

2007-10-23 Thread Tolga Uzuner
Dear R Users, I am having trouble using R from within Excel. I've installed R(D) Com Client and then try to open up the first sample sheet. As Excel executes auto_open, it stops at function "ExcelVersionMajor" and complaines that a certain type library is missing: missing rcom 1.0 type libra