Re: [R] Percentile bootstrap for the median : error message

2022-01-08 Thread Fox, John
Dear Sacha, Here's your corrected and cleaned-up code: > library(boot) > set.seed(123) > s <- rnorm(10,0,1) > (m <- median(s)) [1] 0.000946463 > med <- function(d,i) { + median(d[i, ]) + } > set.seed(456) > N <- 100 > n<-5 > out <- replicate(N, { + dat <- data.frame(sample(s,size=n))

Re: [R] Speed up studentized confidence intervals ?

2021-12-29 Thread Fox, John
Dear varin sacha, You didn't correctly adapt the code to the median. The outer call to mean() in the last line shouldn't be replaced with median() -- it computes the proportion of intervals that include the population median. As well, you can't rely on the asymptotics of the bootstrap for a

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Fox, John
{ idx <- expr D[ col, idx ] <- otherexpr } are reasonable, when for ( col in colnames( col ) ) { idx <- expr D[[ col ]][ idx ] <- otherexpr } does actually run significantly faster. On December 21, 2021 9:28:52 AM PST, "Fox, Joh

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Fox, John
Dear Jeff, On 2021-12-21, 11:59 AM, "R-help on behalf of Jeff Newmiller" wrote: Intuitive, perhaps, but noticably slower. I think that in most applications, one wouldn't notice the difference; for example: > D <- data.frame(matrix(rnorm(1000*1e6), 1e6, 1000)) > microbenchmark(D[, 1])

Re: [R] Character (1a, 1b) to numeric

2020-07-10 Thread Fox, John
ata.frame (xc = xc, xnew = xnew) >xc xnew > 1 1a 1.3 > 2 2 2.0 > 3 1c 1.7 > 4 1c 1.7 > 5 1b 1.5 > 6 1a 1.3 > 7 2 2.0 > 8 2 2.0 > 9 1a 1.3 > 10 1a 1.3 > 11 2c 2.7 > 12 1b 1.5 > 13 1b 1.5 > 14 1 1.0 > 15 1c 1.7 > >

Re: [R] Character (1a, 1b) to numeric

2020-07-10 Thread Fox, John
ach: > > xc <- c("1", "1a", "1b", "1c", "2", "2a", "2b", "2c") > xn <- as.numeric(gsub("a", ".3", gsub("b", ".5", gsub("c", ".7", xc > xn >

Re: [R] Character (1a, 1b) to numeric

2020-07-10 Thread Fox, John
Dear Jean-Louis, There must be many ways to do this. Here's one simple way (with no claim of optimality!): > xc <- c("1", "1a", "1b", "1c", "2", "2a", "2b", "2c") > xn <- c(1, 1.3, 1.5, 1.7, 2, 2.3, 2.5, 2.7) > > set.seed(123) # for reproducibility > x <- sample(xc, 20, replace=TRUE) # "data"

Re: [R] plot shows exponential values incompatible with data

2020-07-10 Thread Fox, John
Dear Jim, As I pointed out yesterday, setting ylim as you suggest still results in "0e+00" as the smallest tick mark, as it should for evenly spaced ticks. Best, John > On Jul 10, 2020, at 12:13 AM, Jim Lemon wrote: > > Hi Luigi, > This is a result of the "pretty" function that calculates

Re: [R] plot shows exponential values incompatible with data

2020-07-09 Thread Fox, John
gt;> >> Thank you, >> but why it does not work in linear? With the log scale, I know it >> works but I am not looking for it; is there a way to force a linear >> scale? >> Regards >> Luigi >> >>> On Thu, Jul 9, 2020 at 3:44 PM Fox, John wrote: >

Re: [R] plot shows exponential values incompatible with data

2020-07-09 Thread Fox, John
(2, at=c(1e9, (1:6)*1e11)) But now the ticks aren't evenly spaced (though they appear to be because, as I mentioned, 10^9 is "close" to 0). Best, John > Regards > Luigi > > On Thu, Jul 9, 2020 at 3:44 PM Fox, John wrote: >> >> Dear Luigi, >> >>>

Re: [R] plot shows exponential values incompatible with data

2020-07-09 Thread Fox, John
Dear Luigi, > On Jul 9, 2020, at 8:59 AM, Luigi Marongiu wrote: > > Hello, > I have these vectors: > ``` > X <- 1:7 > Y <- c(1438443863, 3910100650, 10628760108, 28891979048, 78536576706, > 213484643920, 580311678200) > plot(Y~X) > ``` > The y-axis starts at 0e0, but the first value is 1.4

Re: [R] [Rd] R 4.0.2 scheduled for June 22

2020-06-09 Thread Fox, John
Dear Peter, Thank you very much for this. To clarify slightly, the bug affects not just the Rcmdr package but use of the tcltk package on Windows more generally. Best, John - John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada Web:

Re: [R] R 4.0.1 crashes with R Commander

2020-06-08 Thread Fox, John
Dear Paulo, This is due to a known bug in R 4.0.1 for Windows that is general to Tcl/Tk. The bug should be fixed in the current patched version of R 4.0.1 for Windows, so you could use that or just go back to R 4.0.0. Best, John - John Fox, Professor Emeritus

Re: [R] "effects" package with "lme4"

2020-05-15 Thread Fox, John
---- Best, John > > Best, > Axel. > > > >> On May 15, 2020, at 5:51 PM, Fox, John wrote: >> >> Dear Axel, >> >> There only one fixed effect in the model, ns(Days, 3), so I don't know what >> you expected. >> >> Be

Re: [R] "effects" package with "lme4"

2020-05-15 Thread Fox, John
age- > From: Axel Urbiz > Sent: Friday, May 15, 2020 5:33 PM > To: Fox, John ; R-help@r-project.org > Subject: "effects" package with "lme4" > > Hello John and others, > > I’d appreciate your help as I’m trying to plot the effect of predictor > “

Re: [R] Loop inside dplyr::mutate

2020-05-09 Thread Fox, John
Dear Axel, Assuming that you're not wedded to using mutate(): > D1 <- 1 - as.matrix(sim_data_wide[, 2:11]) > D2 <- matrix(0, 10, 10) > colnames(D2) <- paste0("PC_", 1:10) > for (i in 1:10) D2[, i] <- 1 - apply(D1[, 1:i, drop=FALSE], 1, prod) > all.equal(D2, as.matrix(sim_data_wide[, 22:31])) [1]

Re: [R] possible issue with scatterplot function in car package

2020-05-03 Thread Fox, John
ch for your time > > Yousri Fanous > > Software Developer > IBM CANADA > > On Sat, May 2, 2020 at 11:47 PM Fox, John wrote: > > Dear Yousri, > > Yes, this is clearly a bug, and almost surely a long-standing one. We'll fix > it in the next release of th

Re: [R] possible issue with scatterplot function in car package

2020-05-02 Thread Fox, John
Dear Yousri, Yes, this is clearly a bug, and almost surely a long-standing one. We'll fix it in the next release of the car package. BTW, stringsAsFactors defaults to FALSE in R 4.0.0 (and you don't use the ch variable in the example). Also, although it has no bearing on the bug, I'd

Re: [R] Rtools required

2020-04-29 Thread Fox, John
> -Original Message- > From: Bert Gunter > Sent: Wednesday, April 29, 2020 5:50 PM > To: Steven > Cc: Fox, John ; R-help Mailing List project.org> > Subject: Re: [R] Rtools required > > Type > ?.Renviron > ?R.home > ?"environment variables"

Re: [R] Rtools required

2020-04-28 Thread Fox, John
Dear Steven, > -Original Message- > From: Steven > Sent: Tuesday, April 28, 2020 9:50 AM > To: Fox, John > Cc: R-help Mailing List > Subject: Re: [R] Rtools required > > Hello John, > > Perhaps you can help me. I am an idiot. I visited the Rtoo

Re: [R] Rtools required

2020-04-28 Thread Fox, John
Dear Steven, Did you follow the instruction on the Rtools webpage to add PATH="${RTOOLS40_HOME}\usr\bin;${PATH}" to your .Renviron file? I hope this helps, John - John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada Web:

Re: [R] deciphering help for `attach`

2020-04-27 Thread Fox, John
Dear Bert, > -Original Message- > From: Bert Gunter > Sent: Monday, April 27, 2020 11:26 AM > To: Fox, John > Cc: edwar...@psu.ac.th; r-help@r-project.org > Subject: Re: [R] deciphering help for `attach` > > What is the use case for attach?

Re: [R] deciphering help for `attach`

2020-04-27 Thread Fox, John
Dear Edward, Paragraph 4 in the help page goes on to say, "Rather, a new environment is created on the search path and the elements of a list (including columns of a data frame) or objects in a save file or an environment are copied into the new environment." That seems reasonably clear to

Re: [R] Correct way to cite R and RStudio in a manuscipt

2020-04-15 Thread Fox, John
Dear John, For R, see citation() . Best, John - John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada Web: http::/socserv.mcmaster.ca/jfox > On Apr 15, 2020, at 10:16 AM, Sorkin, John wrote: > > What is the proper way to cite R and

Re: [R] Problem launching Rcmdr

2020-03-16 Thread Fox, John
r assistance, > > Brian > > On Tue, Mar 10, 2020 at 8:46 AM Fox, John wrote: > Dear Brian, > > Normally I'd expect that a workspace saved from a previous session and loaded > at the start of the current session would cause this kind of anomalous > behaviour, but th

Re: [R] Problem launching Rcmdr

2020-03-11 Thread Fox, John
hange the graph > accordingly.The interesting thing is that after the tkdestroy(tt) command I > tried running library(Rcmdr) and it launched successfully. I'm not sure what > that means, but hopefully someone else will. > > Thank you, > > Brian > > On Wed, Mar 11, 2020 at 1:02 P

Re: [R] Problem launching Rcmdr

2020-03-11 Thread Fox, John
ck(but.w <- tkbutton(tt, text = "Submit", command = eval.txt)) ## Try pressing the button, edit the text and when finished: tkdestroy(tt) snip -- Best, John > -Original Message- > From: Pfaff, Bernhard Dr. > Sent: Wednesday, March 11, 20

Re: [R] Problem launching Rcmdr

2020-03-10 Thread Fox, John
into a personal library. Best, John > -Original Message- > From: Brian Grossman > Sent: Tuesday, March 10, 2020 5:07 PM > To: Fox, John > Subject: Re: [R] Problem launching Rcmdr > > John, > > Thanks for the reply. Here is the output from running s

Re: [R] Problem launching Rcmdr

2020-03-10 Thread Fox, John
Dear Brian, Normally I'd expect that a workspace saved from a previous session and loaded at the start of the current session would cause this kind of anomalous behaviour, but that doesn't explain why the Rcmdr starts up properly in a second (concurrent?) session, nor why it doesn't start up

Re: [R] issue with Rcmdr

2020-01-06 Thread Fox, John
Dear Toufik, > -Original Message- > From: Toufik Zahaf > Sent: Monday, January 6, 2020 4:07 PM > To: Jeff Newmiller > Cc: r-help@r-project.org; Fox, John ; tzahaf > > Subject: Re: [R] issue with Rcmdr > > Dears > > Thanks a lot , I understand that may

Re: [R] issue with Rcmdr

2020-01-06 Thread Fox, John
Dear Toufik, You've already had a suggestion to check whether RcmdrMisc is installed. It should have been installed automatically when you installed the Rcmdr package. If RcmdrMisc is installed, see whether you can load it directly via the command library(RcmdrMisc). If that too fails, you

Re: [R] Where is the SD in output of glm with Gaussian distribution

2019-12-09 Thread Fox, John
Dear Bert, It's perhaps a bit pedantic to point it out, but the dispersion is estimated from the Pearson statistic (sum of squared residuals or weighted squared residuals) not from the residual deviance. You can see this in the code for summary.glm(). Best, John

Re: [R] Where is the SD in output of glm with Gaussian distribution

2019-12-09 Thread Fox, John
Dear Marc, For your simple model, the standard deviation of y is the square-root of the estimated dispersion parameter: > set.seed(123) > y <- rnorm(100) > gnul <- glm(y ~ 1) > summary(gnul) Call: glm(formula = y ~ 1) Deviance Residuals: Min1QMedian3Q Max

Re: [R] R commander (Rcmdr) won't start [SOLVED]

2019-12-08 Thread Fox, John
gt; community, both with your package and your replies to this forum, which shows > you're a really kind person and deserve all our appreciation. Thank you for your very kind remarks. Best, John > Best wishes > Gabriele Pallotti (Italy) > > > > > Il giorno ven 6 dic 2019 al

Re: [R] R commander (Rcmdr) won't start [SOLVED]

2019-12-06 Thread Fox, John
Dear Gabriele, I'm glad that you were able to solve your problem. I spent a bit of time today updating my R from 3.6.0 to 3.6.1 and updating all R packages on Ubuntu, and, for what is now an obvious reason, I was unable to duplicate the problem. Saving the .Rhistory file is benign but saving

Re: [R] Orthogonal polynomials used by R

2019-11-28 Thread Fox, John
Dear Ashim, Please see my brief remarks below: > On Nov 28, 2019, at 11:02 AM, Ashim Kapoor wrote: > > On Thu, Nov 28, 2019 at 7:38 PM Fox, John wrote: > >> Dear Ashim, >> >> I'm afraid that much of what you say here is confused. >> >> First, bec

Re: [R] Orthogonal polynomials used by R

2019-11-28 Thread Fox, John
ta = mydf,glm(gdp~1+x+x^2+x^3+x^4+x^5+x^6),K=10)$delta[1])) > > print(d1) > ## [1] 2.149647e+13 2.253999e+13 2.182175e+13 2.177170e+13 2.198675e+13 > ## [6] 2.145754e+13 > > # here it chooses 1 or 6 > > Query : Why does it choose 1? Notice : Is this just round off noise / no

Re: [R] Orthogonal polynomials used by R

2019-11-27 Thread Fox, John
Dear Ashim, Orthogonal polynomials are used because they tend to produce more accurate numerical computations, not because their coefficients are interpretable, so I wonder why you're interested in the coefficients. The regressors produced are orthogonal to the constant regressor and are

Re: [R] Help Installing Rtools

2019-09-06 Thread Fox, John
Dear Harold, Have you checked that the Rtools directory is on the Windows path? If not, you could try rerunning the Rtools installer and allow it to modify the path, or simply add the Rtools directory to the path yourself. I hope that this helps, John - John

Re: [R] [effects] allEffects does not accept integer value for xlevels

2019-09-04 Thread Fox, John
N. Best, John > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rolf > Turner > Sent: Wednesday, September 4, 2019 5:39 PM > To: Fox, John > Cc: r-help@r-project.org; sa...@umn.edu > Subject: Re: [R] [effects] allEffects does not accept int

Re: [R] [effects] allEffects does not accept integer value for xlevels

2019-09-04 Thread Fox, John
Dear Gerrit, Yes, that appears to be a bug in Effect() -- too bad that it wasn't discovered earlier because a new version of the package was submitted yesterday, but thank you for the bug report. We'll fix the bug, but until then a work-around is to specify the number of levels for each

Re: [R] Increasing number of observations worsen the regression model

2019-05-26 Thread Fox, John
Dear Raffaele, Using your code, with one modification -- setting the seed for R's random number generator to make the result reproducible -- I get: > set.seed(12345) . . . > lmMod <- lm(yvar~xvar) > print(summary(lmMod)) Call: lm(formula = yvar ~ xvar) Residuals: Min 1Q Median

Re: [R] Memmory issue

2019-05-06 Thread Fox, John
Dear Ravindra, My guess is that you're using the 32-bit version of R for Windows rather than the 64-bit version. Read question 2.9 in the R FAQ for Windows . If this is the case, the

Re: [R] lm fails on some large input

2019-04-18 Thread Fox, John
Dear Dingyuan Wang, But your question was answered clearly earlier in this thread (I forget by whom), showing that lm() provides the solution to the regression of x on y if the criterion for singularity is tightened: > lm(x ~ y) Call: lm(formula = x ~ y) Coefficients: (Intercept)

Re: [R] lm fails on some large input

2019-04-18 Thread Fox, John
Dear Peter, > -Original Message- > From: peter dalgaard [mailto:pda...@gmail.com] > Sent: Thursday, April 18, 2019 12:23 PM > To: Fox, John > Cc: Michael Dewey ; Dingyuan Wang > ; r-help@r-project.org > Subject: Re: [R] lm fails on some large input > > Um,

Re: [R] lm fails on some large input

2019-04-18 Thread Fox, John
Dear Michael and Dingyuan Wang, > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Michael > Dewey > Sent: Thursday, April 18, 2019 11:25 AM > To: Dingyuan Wang ; r-help@r-project.org > Subject: Re: [R] lm fails on some large input > > Perhaps subtract

Re: [R] isSingular for lm?

2019-04-05 Thread Fox, John
Hi Peter, > On Apr 5, 2019, at 7:22 AM, peter dalgaard wrote: > > Can't you just check for NA coefficients? > >> y <- rnorm(10) ; x <- rep(0,10) >> coef(lm(y~x)) > (Intercept) x > -0.0962404 NA > > so > >> any(is.na(coef(lm(y~x > [1] TRUE > > I have a vague

Re: [R] Potential Issue with lm.influence

2019-04-03 Thread Fox, John
ally studentized residual). > > I just think some more specificity could be of use for future users, to > make the R:stats community even better :) Does that make sense? > > Sincerely, > Eric > > On Tue, Apr 2, 2019 at 7:53 PM Fox, John wrote: > >> Dear Eric, >&

Re: [R] Potential Issue with lm.influence

2019-04-03 Thread Fox, John
9 10 11 12 > 3.531271e+17 2.295015e+01 1.739889e+01 1.058165e+00 1.058041e+00 1.057957e+00 > 13 > 1.058217e+00 > > > so the model of fit3 predicts that Jupiter and Saturn should have several > bazillions of moons each! >

Re: [R] Fwd: Potential Issue with lm.influence

2019-04-02 Thread Fox, John
Dear Eric, Have you looked at your data? -- for example: plot(log(Moons) ~ Volume, data = moon_data) text(log(Moons) ~ Volume, data = moon_data, labels=Name, adj=1, subset = Volume > 400) The negative-binomial model doesn't look reasonable, does it? After you eliminate Jupiter

Re: [R] Multilevel models

2019-03-04 Thread Fox, John
Dear Saul, The most commonly used mixed-effect models software in R, in the lme4 and nlme packages, use the Laird-Ware form of the model, which isn't explicitly hierarchical. That is, higher-level variables are simply invariant within groups and appear in the model formula in the same manner

Re: [R] Obtaining values of estimates from a regression; How do I get values from a list?

2019-02-22 Thread Fox, John
Dear John, This seems to be more complicated than it needs to be. One normally uses coef() to extract coefficients from a model object. Thus > coef(fitchange) (Intercept) pre -54.1010158 0.6557661 > coef(fitchange)[2] pre 0.6557661 Best, John

Re: [R] adding a hex sticker to a package

2019-01-21 Thread Fox, John
Dear Terry, I added a hex sticker to the effects package, and there will be one in the next versions of the car and Rcmdr packages. I put a pdf with the hex sticker in install/docs, and display it with the function effectsHexsticker(); see ?effectsHexsticker. I imagine that there are other

Re: [R] importing data error question

2019-01-18 Thread Fox, John
Dear Jihee, > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of ??? > Sent: Wednesday, January 16, 2019 7:02 PM > To: Fox, John > Cc: r-help@r-project.org > Subject: Re: [R] importing data error question > > Thanks for your

Re: [R] importing data error question

2019-01-18 Thread Fox, John
. ;( > I might give up from now,, > > > Thanks again! > > Best, > Jihee > > > > From: "Fox, John" > Sent: Friday, January 18, 2019 12:02:42 AM > To:"우지희" > Cc:"" > Subject:Re: [R] importing data

Re: [R] importing data error question

2019-01-17 Thread Fox, John
an't detect. Best, John > On Jan 17, 2019, at 12:24 AM, 우지희 wrote: > > Dear John, > > I tried with your file. R commander could read the file but there's still no > active dataset > > Anyway I'll send my file, too > > Jihee > > <528c421a382d426

Re: [R] importing data error question

2019-01-16 Thread Fox, John
t {r} message at R Markdown. > > There's no dataset. > > i tried both .xls and .xlsx . > > > Jihee > > > > > > > > From: "Fox, John" > Sent: Thursday, January 17, 2019 10:59:44 AM > To:"우지희" > Cc:""

Re: [R] importing data error question

2019-01-16 Thread Fox, John
commander"? I have no > idea why it doesn't change. > > Best, > Jihee > > From: "Fox, John" > Sent: Thursday, January 17, 2019 1:59:03 AM > To:"우지희" > Cc:"r-help@r-project.org" > Subject:Re: [R] importing data error question >

Re: [R] importing data error question

2019-01-16 Thread Fox, John
sue. John > On Jan 14, 2019, at 11:36 PM, Fox, John wrote: > > Dear jihee, > >> On Jan 14, 2019, at 9:00 PM, 우지희 wrote: >> >> You said previously that you were using a Mac, so I'm surprised that you now >> say that you're using Windows. I don't have a Windows 7 sys

Re: [R] importing data error question

2019-01-14 Thread Fox, John
now what is plain-text data file. A plain-text data file could, e.g., be created from an Excel file by exporting a worksheet as a .csv (comma-separated-values) file; you could read this into the Rcmdr via Data > Import data > from text file, specifying the field separator as commas. >

Re: [R] importing data error question

2019-01-14 Thread Fox, John
Dear jihee, > On Jan 13, 2019, at 9:28 PM, 우지희 wrote: > > > > From: "우지희" > Sent: Monday, January 14, 2019 9:40:26 AM > To:"Fox, John" > Subject:Re: [R] importing data error question > > > Thanks for your replies. > > I'm

Re: [R] importing data error question

2019-01-11 Thread Fox, John
Dear Petr and jihee, The Rcmdr can import Excel files, and as I just verified, it can do so on a Mac listing files of all types (*) in the open-file dialog box (which is the default). So, as Petr suggests, more information is required to help you, including the versions of macOS, R, and all

Re: [R] Strange degrees of freedom and SS from car::Anova with type II SS?

2018-12-05 Thread Fox, John
Dear R., The problem you constructed is too ill-conditioned for the method that Anova() uses to compute type-II sums of squares and the associated degrees of freedom, with an immense condition number of the coefficient covariance matrix: > library(car) Loading required package: carData > mod

Re: [R] Question Mixed-Design Anova in R

2018-11-23 Thread Fox, John
Dear Lisa, > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of peter > dalgaard > Sent: Friday, November 23, 2018 10:16 AM > To: Lisa van der Burgh <40760...@student.eur.nl> > Cc: r-help@R-project.org > Subject: Re: [R] Question Mixed-Design Anova in R >

Re: [R] unique() duplicate() not what i am looking for

2018-11-19 Thread Fox, John
Dear Knut, Here's one way: > as.vector((table(Dup) > 1)[Dup]) [1] TRUE TRUE TRUE FALSE TRUE TRUE TRUE FALSE Someone will probably think of something cleverer. I hope this helps, John -- John Fox, Professor Emeritus McMaster University Hamilton,

Re: [R] The Suggests field in a DESCRIPTION file.

2018-11-17 Thread Fox, John
Dear Rolf, "fortunes" needs to be quoted in requireNamespace("fortunes", quietly=TRUE). I hope this helps, John - John Fox Professor Emeritus McMaster University Hamilton, Ontario, Canada Web:

Re: [R] Line with linearly changing thickness – installation issues

2018-11-11 Thread Fox, John
oo short" usr <- par("usr") units <- (usr[4] - usr[3])*unit/2 x <- c(x, rev(x)) y <- c(y + thickness*units, rev(y) - rev(thickness)*units) polygon(x=x, y=y, col=col, border=col) } Best, John > -Original Message----- > From: R-help [

Re: [R] Line with linearly changing thickness – installation issues

2018-11-11 Thread Fox, John
Dear David and Ferri, Here's a simple implementation using polygon() (as David suggested). It's much less sophisticated than Paul Murrell's -- in particular, the ends of the line are simply vertical (but, with a bit more work, that too could be addressed) -- and uses standard R graphics rather

Re: [R] Sum of Squares Type I, II, III for ANOVA

2018-11-06 Thread Fox, John
pinion, should be on what hypotheses are being tested. If you want to see more detail, you could consult the book with which the car package is associated: see citation(package="car"). Best, John > -----Original Message- > From: Thanh Tran [mailto:masternha...@gmail.com] >

Re: [R] Sum of Squares Type I, II, III for ANOVA

2018-11-06 Thread Fox, John
Dear Nhat Tran, One more thing: You could specify the model even more compactly as mod <- lm(KIC ~ (tem + ac + av + thick)^2) Best, John > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Fox, John > Sent: Tuesday, November 6,

Re: [R] Sum of Squares Type I, II, III for ANOVA

2018-11-06 Thread Fox, John
Dear Nhat Tran, The output that you show is unreadable and as far as I can see, the data aren't attached, but perhaps the following will help: First, if you want Anova() to compute type III tests, then you have to set the contrasts properly *before* you fit the model, not after. Second, you

Re: [R] "logical indexing, " [was] match() question or needle haystack problem for a data.frame

2018-10-26 Thread Fox, John
Dear Knut, > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Knut > Krueger > Sent: Friday, October 26, 2018 2:29 AM > To: r-help mailing list > Subject: Re: [R] "logical indexing, " [was] match() question or needle > haystack > problem for a

[R] new edition of An R Companion to Applied Regression

2018-10-15 Thread Fox, John
Dear r-help list members, Sandy Weisberg and I would like to announce a new (third) edition of our book An R Companion to Applied Regression, which has recently been published by Sage Publications. The book provides a broad introduction to R in the general context of applied regression

Re: [R] Problem with lm.resid() when weights are provided

2018-09-17 Thread Fox, John
Dear Hamed, > -Original Message- > From: Hamed Ha [mailto:hamedhas...@gmail.com] > Sent: Monday, September 17, 2018 3:56 AM > To: Fox, John > Cc: r-help@r-project.org > Subject: Re: [R] Problem with lm.resid() when weights are provided > > H i John, > &g

Re: [R] Problem with lm.resid() when weights are provided

2018-09-14 Thread Fox, John
Please feel free to contact me for more details if required. > > Warm regards, > Hamed. > > > > > > > > > > On Fri, 14 Sep 2018 at 13:35, Fox, John <mailto:j...@mcmaster.ca> > wrote: > > > Dear Hamed, > > I don't think that anyone has picke

Re: [R] Problem with lm.resid() when weights are provided

2018-09-14 Thread Fox, John
Dear Hamed, I don't think that anyone has picked up on this problem. What's peculiar about your weights is that several are 0 within rounding error but not exactly 0: > head(df) y x weight 1 1.5115614 0.5520924 2.117337e-34 2 -0.6365313 -0.1259932 2.117337e-34 3

Re: [R] Marginal effects with plm

2018-09-06 Thread Fox, John
from the plm package. It would probably require substantial effort to get this to work. Best, John > -----Original Message- > From: Miluji Sb [mailto:miluj...@gmail.com] > Sent: Thursday, September 6, 2018 8:52 AM > To: Fox, John > Cc: r-help mailing list > Subject: R

Re: [R] Marginal effects with plm

2018-09-06 Thread Fox, John
your question. Best, John > -Original Message- > From: Miluji Sb [mailto:miluj...@gmail.com] > Sent: Thursday, September 6, 2018 5:37 AM > To: Fox, John > Cc: r-help mailing list > Subject: Re: [R] Marginal effects with plm > > Dear John, > > Thank

Re: [R] Marginal effects with plm

2018-09-05 Thread Fox, John
Dear Milu, Depending upon what you mean by "marginal effects," you might try the effects package. For example, for your model, try (Ef.hd <- Effect(c("heat", "debt_dummy"), plm1)) plot(Ef.hd) A couple of comments about the model: I'd prefer to specify the formula as log(y) ~

Re: [R] standardized regression coefficients in GAM

2018-08-30 Thread Fox, John
Dear Dani, I'll address your questions briefly below. They aren't unique to GAMs. > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of dani > Sent: Thursday, August 30, 2018 12:47 PM > To: r-help@r-project.org > Subject: [R] standardized regression

Re: [R] Obtaining Complete Dataset with Imputed Values

2018-08-30 Thread Fox, John
Dear Paul and WHP, My guess: Paul apparently has loaded the mice package after the mi package. Both packages have complete() functions, but for objects of different classes -- "mids" in the case of mice. Consquently, complete() in the mice package is shadowing complete() in the mi package.

Re: [R] graphing repeated curves

2018-08-22 Thread Fox, John
Dear Bert, > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter > Sent: Wednesday, August 22, 2018 8:38 PM > To: Jim Lemon > Cc: rss@gmail.com; R-help > Subject: Re: [R] graphing repeated curves > > I do not think this does what the OP

Re: [R] graphing repeated curves

2018-08-22 Thread Fox, John
Dear Richard, How about this: ord <- order(mtcars$hp) mtcars$hp <- mtcars$hp[ord] mtcars$mpg <- mtcars$mpg[ord] plot(mpg ~ hp, data=mtcars) for (p in 1:6){ m <- lm(mpg ~ poly(hp, p), data=mtcars) lines(mtcars$hp, fitted(m), lty=p, col=p) } legend("topright", legend=1:6, lty=1:6, col=1:6,

Re: [R] looking for formula parser that allows coefficients

2018-08-21 Thread Fox, John
Dear Paul, Is it possible that you're overthinking this? That is, to you really need an R model formula or just want to evaluate an arithmetic expression using the columns of X? If the latter, the following approach may work for you: > evalFormula <- function(X, expr){ + if

Re: [R] Formatting multi-way ANOVA output for spectra analysis

2018-07-25 Thread Fox, John
Dear Robert, Although you don't say so, it sounds as if you may be using the Anova() function in the car package, which is what the R Commander uses for ANOVA. If so, in most cases, Anova() returns an object of class c("anova", "data.frame"), which can be manipulated as a data frame. To see

Re: [R] Package 'data.table' in version R-3.5.0 not successfully being installed

2018-04-27 Thread Fox, John
> -Original Message- > From: Akhilesh Singh [mailto:akhileshsingh.i...@gmail.com] > Sent: Friday, April 27, 2018 4:10 AM > To: Fox, John <j...@mcmaster.ca> > Cc: r-help mailing list <r-help@r-project.org> > Subject: Re: [R] Package 'data.table' in version R-3.5.0 not suc

Re: [R] Package 'data.table' in version R-3.5.0 not successfully being installed

2018-04-27 Thread Fox, John
Dear Peter, > -Original Message- > From: peter dalgaard [mailto:pda...@gmail.com] > Sent: Friday, April 27, 2018 8:47 AM > To: Dénes Tóth <toth.de...@kogentum.hu> > Cc: Akhilesh Singh <akhileshsingh.i...@gmail.com>; r-help mailing list h...@r-project.org>

Re: [R] Package 'data.table' in version R-3.5.0 not successfully being installed

2018-04-26 Thread Fox, John
in data.table appear to work under R 2.5.0, so it's possible that (much of) the functionality of the package is intact. Best, John > -Original Message- > From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] > Sent: Thursday, April 26, 2018 12:14 PM > To: Fox, John <j...@mcmaste

Re: [R] Package 'data.table' in version R-3.5.0 not successfully being installed

2018-04-26 Thread Fox, John
Dear A.K. Singh, As you discovered, the data.table package has an error under R 3.5.0 that prevents CRAN from distributing a Windows binary for the package. The reason that you weren't able to install the package from source is apparently that you haven't installed the R package-building tools

Re: [R] questions about performing Robust multiple regression using bootstrap

2018-02-26 Thread Fox, John
Dear Faiz, Bootstrapping R^2 using Boot() is straightforward: Simply write a function that returns R^2, possibly in a vector with the regression coefficients, and use it as the f argument to Boot(). That will get you, e.g., bootstrapped confidence intervals for R^2. (Why you want that is

Re: [R] Parallel assignments and goto

2018-02-14 Thread Fox, John
Dear Thomas, This looks like a really interesting project, and I don't think that anyone responded to your message, though I may be mistaken. I took at a look at implementing parallel assignment, and came up with: passign <- function(..., envir=parent.frame()){ exprs <- list(...) vars

Re: [R] effects & lme4: error since original data frame notfoundWASeffects: error when original data frame is missing

2018-01-17 Thread Fox, John
Dear Gerrit, This issue is discussed in a vignette in the car package (both for functions in the car and effects packages): vignette("embedding", package="car") . The solution suggested there is the essentially the one that you used. I hope this helps, John - John

Re: [R] About levene.test

2018-01-15 Thread Fox, John
Dear Mariano, See the function leveneTest() in the car package. I hope that this helps, John - John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada Web: socialsciences.mcmaster.ca/jfox/ > -Original Message- > From: R-help

Re: [R] SpreadLevelPlot for more than one factor

2018-01-14 Thread Fox, John
e effects >of factor wool and tension @ each level of the other. Is that correct? >Are (a) and (b) the distribution of the main effect of wool and tension? >Please confirm. > > > >Best Regards, >Ashim > > > > > > > > > >On Sun, Jan 7, 2018 at

Re: [R] SpreadLevelPlot for more than one factor

2018-01-07 Thread Fox, John
Dear Ashim, Try spreadLevelPlot(breaks ~ interaction(tension, wool), data=warpbreaks) . I hope this helps, John - John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada Web: socialsciences.mcmaster.ca/jfox/ > -Original Message- > From:

Re: [R] Primer for working with survey data in R

2017-11-11 Thread Fox, John
Dear Kevin, In addition to the advice you've received, take a look at the survey package. It's not quite what you're asking for, but in fact it's probably more useful, in that it provides correct statistical inference for data collected in complex surveys. The package is described in an

Re: [R] error to run this package

2017-10-31 Thread Fox, John
Dear John and Anima, I didn't reply earlier because other people got to it before I did and because, given the lack of information in the original post, there wasn't anything to add. The car package shouldn't require anything near 2.5 Gb to load. Here's what I get under Windows 10 with R

Re: [R] bowed linear approximations

2017-09-26 Thread Fox, John
of your problem. Best, John > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Evans, > Richard K. (GRC-H000) > Sent: Tuesday, September 26, 2017 10:01 AM > To: Eric Berger <ericjber...@gmail.com>; Fox, John <j...@mcmaster.ca> &

Re: [R] bowed linear approximations

2017-09-25 Thread Fox, John
Dear Rich, Assuming that I understand what you want to do, try adding the following to your script (which, by the way, is more complicated that it needs to be): xx <- 10:50 m <- lm(y ~ x) yy <- predict(m, data.frame(x=xx)) lines(spline(xx, yy), col="blue") m <- lm(y ~ log(x)) yy <- predict(m,

Re: [R] Loading Rcmdr

2017-07-25 Thread Fox, John
Dear Jack, There's not enough information here to know what the problem might be. Please see < https://www.r-project.org/help.html>, in particular the section on asking for help, and follow the link to the posting guide. At a minimum, explain what you did and what happened. It's generally

  1   2   >