[R] function pointers?

2017-11-22 Thread Paul Johnson
We have a project that calls for the creation of a list of many distribution objects. Distributions can be of various types, with various parameters, but we ran into some problems. I started testing on a simple list of rnorm-based objects. I was a little surprised at the RAM storage requirements,

Re: [R] [ESS] M-x R gives no choice of starting dir

2017-12-13 Thread Paul Johnson
If Emacs is not asking for starting directory, it is very likely your init file has this somewhere: (setq ess-ask-for-ess-directory nil) On Mon, Sep 11, 2017 at 3:23 PM, Enrico Schumann wrote: > On Mon, 11 Sep 2017, Christian writes: > >> Hi, >> >> I experienced a sudden change in the behavior

[R] Interesting quirk with fractions and rounding

2017-04-20 Thread Paul Johnson
Hello, R friends My student unearthed this quirk that might interest you. I wondered if this might be a bug in the R interpreter. If not a bug, it certainly stands as a good example of the dangers of floating point numbers in computing. What do you think? > 100*(23/40) [1] 57.5 > (100*23)/40 [1

Re: [R] Prediction plots

2017-04-21 Thread Paul Johnson
I have done this a lot. Would you mind installing my pkg rockchalk and then run example(plotSlope) and example(plotCurve)? If the output is close to what you want, you can adjust my code. The vignette explains. 1. Create newdata object 2. Run that through predict 3. Make plot None of this is rock

Re: [R] Peformance question

2017-04-21 Thread Paul Johnson
I dont understand your code. But I do have suggestion. Run the functions in the profiler, maybe differences will point at the enemy. Know what I mean? Rprof('check.out') #run code Rprof(NULL) summaryRprof('check.out') Do that for each method. That may be uninformative. I wondered if you tried t

Re: [R] Interesting quirk with fractions and rounding

2017-04-21 Thread Paul Johnson
owing accidents from trusting floats. I wonder now if all uses of > or < with numeric variables are suspect. Oh well. If everybody posts their advice, I will write a summary. Paul Johnson University of Kansas On Apr 21, 2017 12:02 AM, "PIKAL Petr" wrote: > Hi > >

Re: [R] Interesting quirk with fractions and rounding

2017-04-22 Thread Paul Johnson
I have to read more books. I studied Golub and van Loan and came away with healthy fear of matrix inversion. But when you look at user contributed regression packages, what do you find? Matrix inversion and lots of X'X. Paul Johnson University of Kansask The key (in your example) is a prope

[R] package building problem Centos 7 & R 3.4.1

2017-08-11 Thread Paul Johnson
Dear everybody: Packages that DO pass the package check on my Ubuntu 17.04 laptop with R 3.4.1 and Mac OSX do not build on Centos 7 with R 3.4.1. I'm pretty sure I have an environment defect, but cannot find it. I find posts from various people about this problem since 2012. But I've checked the

Re: [R] package building problem Centos 7 & R 3.4.1

2017-08-12 Thread Paul Johnson
On Aug 12, 2017 11:58 AM, "José Abílio Matos" wrote: On Friday, 11 August 2017 22.51.12 WEST Paul Johnson wrote: > Dear everybody: > > Packages that DO pass the package check on my Ubuntu 17.04 laptop with > R 3.4.1 and Mac OSX do not build on Centos 7 with R 3.4.1. I

Re: [R] Plotting log transformed predicted values from lme

2017-08-12 Thread Paul Johnson
In the rockchalk package, I have a function called newdata that will help with this. Plenty of examples. Probably my predictOmatic function will just work. Motivation is in the vignette. Paul Johnson University of Kansas On Aug 9, 2017 11:23 AM, "Alina Vodonos Zilberg" wrote: >

[R] workaround for "package building problem Centos 7 & R 3.4.1"

2017-08-14 Thread Paul Johnson
This is for the problem I posted about last Friday. First, the happy part, a workaround: $ cd ~/R/x86_64-redhat-linux-gnu-library/3.4 $ ln -sf /usr/share/R/library/* . After that, all of the packages are found by R CMD check. R CMD check looks in the ~/R/x86_64-redhat-linux-gnu-library/3.4 fold

Re: [R] Install package "diagram"

2017-08-17 Thread Paul Johnson
On Wednesday, August 16, 2017, AbouEl-Makarim Aboueissa < abouelmakarim1...@gmail.com> wrote: > Dear All: > > I am trying to install the package "diagram". It is in the list. But when I > selected the package to install it, it says: > > Question: "would you like to use a personal library instead?"

Re: [R] Transforming data for nice output table

2018-08-21 Thread Paul Johnson
On Mon, Aug 20, 2018 at 2:17 PM David Doyle wrote: > > Hello everyone, > > I'm trying to generate tables of my data out of R for my report. > > My data is setup in the format as follows and the example can be found at: > http://doylesdartden.com/R/ExampleData.csv > > LocationDateYe

[R] looking for formula parser that allows coefficients

2018-08-21 Thread Paul Johnson
Can you point me at any packages that allow users to write a formula with coefficients? I want to write a data simulator that has a matrix X with lots of columns, and then users can generate predictive models by entering a formula that uses some of the variables, allowing interactions, like y ~ 2

Re: [R] Problems to obtain standardized betas in multiply-imputed data

2018-10-05 Thread Paul Johnson
lm.beta, it actually standardizes variables and runs regression. lm.beta resales coefficients instead. Paul Johnson University of Kansas On Wed, Sep 26, 2018, 5:03 AM CHATTON Anne via R-help wrote: > Dear all, > > I am having problems in obtaining standardized betas on a multiply-imput

Re: [R] ANOVA in R

2018-10-10 Thread Paul Johnson
t post hoc comparisons. In car package, Anova function will help. I may teach Anova soon, we'll see if I have better answer then. Paul Johnson University of Kansas On Wed, Oct 10, 2018, 1:14 AM Thanh Tran wrote: > Hi eveyone, > I'm studying about variance (ANOVA) in R and have so

[R] lm equivalent of Welch-corrected t-test?

2018-11-13 Thread Paul Johnson
Long ago, when R's t.test had var.equal=TRUE by default, I wrote some class notes showing that the result was equivalent to a one predictor regression model. Because t.test does not default to var.equal=TRUE these days, I'm curious to know if there is a way to specify weights in an lm to obtain th

[R] Ask if an object will respond to a function or method

2016-03-31 Thread Paul Johnson
In the rockchalk package, I want to provide functions for regression objects that are "well behaved." If an object responds to the methods that lm or glm objects can handle, like coef(), nobs(), and summary(), I want to be able to handle the same thing. It is more difficult than expected to ask a

Re: [R] Error installing packages

2016-10-20 Thread Paul Johnson
On Wed, Oct 19, 2016 at 10:31 AM, David Winsemius wrote: > >> On Oct 19, 2016, at 4:54 AM, Kevin E. Thorpe >> wrote: >> >> Hello. >> >> I am posting this on behalf of one of my students who is getting error >> messages when installing some packages. I have not seen this before nor have >> I be

[R] xvfb? cron job updates R packages, fails on some requiring X11

2017-01-19 Thread Paul Johnson
In Centos 7 systems, I wrote a script that runs on the cron and I notice some package updates and installs fail like this: Error : .onLoad failed in loadNamespace() for 'iplots', details: call: .jnew("org/rosuda/iplots/Framework") error: java.awt.HeadlessException: No X11 DISPLAY variable was

Re: [R] PCA

2010-03-10 Thread Paul Johnson
On Wed, Mar 10, 2010 at 4:42 PM, Xanthe Walker wrote: > Hello, > > I am trying to complete a PCA on a set of standardized ring widths from 8 > different sites (T10, T9, T8, T7, T6, T5, T3, and T2). > The following is a small portion of my data: > > T10 T9 T8 T7 T6 T5 T3 T2 1.33738 0.92669 0.91146

Re: [R] Shade area under curve

2010-03-10 Thread Paul Johnson
I use this to make illustration for some calculus notes. There are examples of shaded areas in there: ### Filename: Normal1_2009_plotmathExample.R ### Paul Johnson June 3, 2009 ### This code should be available somewhere in http://pj.freefaculty.org/R. If it is not ### email me ###Set mu and

[R] Care to share an R presentation?

2010-03-17 Thread Paul Johnson
The R movement is picking up steam in the center of America. People that ignored my R-enthusiasm 10 years ago are now calling me up asking for presentations. I need to make a 2 hour presentation to a collection of faculty and grad students who might like to use R. I don't want to make it seem to

[R] Does S inherit the enhancements in R language?

2010-03-19 Thread Paul Johnson
I don't know anybody who has S-plus these days, but I expect some of you might, and perhaps you won't mind telling me something. I'm working on my presentation about R for the general audience. As I survey the suggestions from this list about that project, I find myself wondering whether S-plus b

Re: [R] How to find the interception point of two linear fitted model in R?

2009-10-21 Thread Paul Johnson
On Wed, Oct 21, 2009 at 12:09 PM, FMH wrote: > Dear All, > > Let have 10 pair of observations, as shown below. > > ## > x <- 1:10 > y <- c(1,3,2,4,5,10,13,15,19,22) > plot(x,y) > ## > > > Two fitted  models, with ranges of [1,5] and [5,10], can be easily fit

[R] spss imports--trouble with to.data.frame

2009-11-13 Thread Paul Johnson
will not be allowed in factors anymore 14: In `levels<-`(`*tmp*`, value = c("Galicia", "Principado de Asturias", ... : duplicated levels will not be allowed in factors anymore 15: In `levels<-`(`*tmp*`, value = c("Stockholm", "", "Sydsverige",

Re: [R] gregmisc library (Mandriva)

2009-11-15 Thread Paul Johnson
On Sat, Oct 3, 2009 at 9:18 AM, chi ball wrote: > > > > Hi, I'm not able to find a rpm of "gregmisc" library (>2.0.0)  for Linux > Mandriva 2008 Spring. > Any suggestion? > Thanks > If you don't find an up to date RPM, either you have to learn how to build an RPM or just install the package yours

[R] why doesn't t.test value include standard error

2009-05-07 Thread Paul Johnson
Hello, everybody! I'm back to ask the obvious on behalf of the silent majority :) Today a student asked me "what standard error was used in this t.test output". I looked into it and was a little surprised that a t.test output object does not have a "slot" for the standard error. Of course, we c

[R] times family unavailable in postscript device (Ubuntu Linux)

2009-05-11 Thread Paul Johnson
I'm running Ubuntu 9.04. I could use some advice about fonts in postscript devices. > sessionInfo() R version 2.9.0 (2009-04-17) i486-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NA

Re: [R] fitdistr for t distribution

2009-05-16 Thread Paul Johnson
On Fri, May 15, 2009 at 6:22 AM, lagreene wrote: > > Thanks Jorge, > > but I still don't understand where they come from.  when I use: > fitdistr(mydata, "t", df = 9) and get values for m and s, and the variance > of my data should be the df/s? > > I jsut want to be able to confirm how m and s are

Re: [R] save the output of summary(lmList(x)) into a dataframe

2009-06-16 Thread Paul Johnson
On Tue, Jun 16, 2009 at 3:29 AM, Cecilia Carmo wrote: > Hi r-helpers! > > I need to save the output of summary() function that I’ve runned like this: > z<- lmList(y~x1+x2| x3, na.action=na.omit,data1,subset=year==1999) > w<-summary(z) > The output (w) is something like this: > Call: >  Model: y ~ x

[R] I want to use Sweave, but only sometimes

2009-04-13 Thread Paul Johnson
Does anybody have a workable system to run an Rnw document through R-Sweave when necessary, but to just run it through LaTeX if no new R calculations are needed? I.e., the figures already exist, I do not need R to do more work for me, so I send the document straight to LaTeX. I want to leave open

Re: [R] Group by in R

2009-04-14 Thread Paul Johnson
On Mon, Apr 13, 2009 at 8:56 AM, Nick Angelou wrote: > >> data >   X1 X2 X3 X4 > 1   1  2  2  1 > 2   1  1  2  2 > 3   1  1  2  2 > 4   2  2  1  2 > 5   1  1  2  2 > 6   2  2  1  2 > 7   1  1  2  1 > 8   2  2  1  2 > 9   1  2  1  1 > 10  1  1  2  2 > > sqldf("select X1, X2, X3, X4, count(*) CNT fr

[R] [R-pkgs] update: rockchalk 1.8.0

2013-07-30 Thread Paul Johnson
This will appear on CRAN mirrors soon. It's my update for Spring, 2013. I keep track of R problems that arise in the regression course and try to facilitate them. There are functions for describing data, presenting regression plots and tables, some regression diagnostics. Most of the usages are il

[R] example to demonstrate benefits of poly in regression?

2013-04-01 Thread Paul Johnson
Here's my little discussion example for a quadratic regression: http://pj.freefaculty.org/R/WorkingExamples/regression-quadratic-1.R Students press me to know the benefits of poly() over the more obvious regression formulas. I think I understand the theory on why poly() should be more numericall

Re: [R] example to demonstrate benefits of poly in regression?

2013-04-01 Thread Paul Johnson
On Mon, Apr 1, 2013 at 12:42 PM, Gabor Grothendieck wrote: > On Mon, Apr 1, 2013 at 1:20 PM, Paul Johnson wrote: > > Here's my little discussion example for a quadratic regression: > > > > http://pj.freefaculty.org/R/WorkingExamples/regression-quadratic-1.R > > &

Re: [R] DUD (Does not Use Derivatives) for nonlinear regression in R?

2013-04-02 Thread Paul Johnson
On Apr 1, 2013 1:10 AM, "qi A" wrote: > > Hi, All > > SAS has DUD (Does not Use Derivatives)/Secant Method for nonlinear > regression, does R offer this option for nonlinear regression? > > I have read the helpfile for nls() and could not find such option, any > suggestion? > nelder-mead is defau

Re: [R] Superscript

2013-04-04 Thread Paul Johnson
On Thu, Apr 4, 2013 at 4:39 AM, Shane Carey wrote: > Hi William, > > for (i in one:length(DATA_names)) > if ((grepl("_",DATA_names[i]))=="TRUE") > DATA_names[i]<-f(DATA_names[i])) > > I keep getting an error saying: incompatible types (from symbol to > character) in subassignment type fix >

Re: [R] Make barplot with error bars, anova out of a table

2013-04-11 Thread Paul Johnson
Hi On Thu, Apr 11, 2013 at 6:43 AM, Simza wrote: > Helo everybody, > I'm new to R and have some issues with my data in R. > > My raw data look like that: > > ID Day size 1 1 7 1 1 7.2 1 1 7.1 2 1 7.3 2 1 7.4 2 1 7.2 3 1 7 3 1 7.1 3 1 > 7.5 4 1 7.3 4 1 7.2 4 1 7.6 1 2 7 1 2 7.2 1 2 7.1 2 2 7.1 2 2

[R] Needed: Beta Testers and Summer Camp Students

2013-04-23 Thread Paul Johnson
Greetings. I'm teaching linear regression this semester and that means I write more functions for my regression support package "rockchalk". I'm at a point now were some fresh eyes would help, so if you are a student in a course on regression, please consider looking over my package overview docu

Re: [R] pglm package: fitted values and residuals

2013-04-24 Thread Paul Johnson
On Wed, Apr 24, 2013 at 3:11 AM, wrote: > I'm using the package pglm and I'have estimated a "random probit model". > I need to save in a vector the fitted values and the residuals of the model > but I can not do it. > > I tried with the command fitted.values using the following procedure without

Re: [R] pglm package: fitted values and residuals

2013-04-25 Thread Paul Johnson
On Wed, Apr 24, 2013 at 4:37 PM, Achim Zeileis wrote: > On Wed, 24 Apr 2013, Paul Johnson wrote: > >> On Wed, Apr 24, 2013 at 3:11 AM, >> wrote: >> >>> I'm using the package pglm and I'have estimated a "random probit model". >>> I n

[R] Trouble with methods() after loading gdata package.

2013-04-30 Thread Paul Johnson
Greetings to r-help land. I've run into some program crashes and I've traced them back to methods() behavior after the package gdata is loaded. I provide now a minimal re-producible example. This seems bugish to me. How about you? dat <- data.frame(x = rnorm(100), y = rnorm(100)) lm1 <- lm(y ~ x

Re: [R] significantly different from one (not zero) using lm

2013-04-30 Thread Paul Johnson
It is easy to construct your own test. I test against null of 0 first so I can be sure I match the right result from summary.lm. ## get the standard error seofb <- sqrt(diag(vcov(lm1))) ## calculate t. Replace 0 by your null myt <- (coef(lm1) - 0)/seofb mypval <- 2*pt(abs(myt), lower.tail = FALSE,

[R] Automatic way to embed fonts into all pdf output?

2013-05-10 Thread Paul Johnson
This is a feature request. Or else a howto request. Can there be some simple, automatic way to make fonts embed into pdf output? Could this be in options() or par()? Why? I recently wanted to create a paper for a conference in a format called AAAI (which I had never heard of before because I liv

Re: [R] R installation error

2013-05-10 Thread Paul Johnson
Meenu: You have an elementary Linux setup and configuration problem to understand first, before you worry about configuring and compiling your own R. I agree strongly that this is something that all linux users should learn to do, but compiling R itself is like climbing Mt Everest as your first m

[R] inverse for formula transformations on LHS

2013-05-17 Thread Paul Johnson
This is an R formula handling question. It arose in class. We were working on the Animals data in the MASS package. In order to see a relationship, you need to log brain and body weight. It's a fun one for teaching regression, if you did not try it yet. There are outliers too! Students wanted to

Re: [R] inverse for formula transformations on LHS

2013-05-21 Thread Paul Johnson
On Sat, May 18, 2013 at 7:05 AM, Stephen Milborrow wrote: > Paul Johnson wrote: >> >> m1 <- lm(log(y) ~ log(x), data = dat) >> >> termplot shows log(y) on the vertical. What if I want y on the vertical? >> > > plotmo in the plotmo package has an inve

[R] recode: how to avoid nested ifelse

2013-06-07 Thread Paul Johnson
f the example became any more complicated. I'm unable to remember a less error prone method :). But I expect you might. Here's my working example code ## Paul Johnson ## 2013-06-07 ## We need to create an ordinal factor from these indicators ## completed elementary school es <- c(0

Re: [R] recode: how to avoid nested ifelse

2013-06-10 Thread Paul Johnson
ed the data generating oracle*, the > > >> pattern: NA, 1, NA, should be a data entry error --- graduating HS > > >> implies graduating ES, no? I would argue fringe cases like that > > >> should be corrected in the data, not through coding work arounds. > &g

[R] Windows R_LIBS_USER confusion under R-3.0.1

2013-06-12 Thread Paul Johnson
I would appreciate ideas about MS Windows install issues. I'm at our stats summer camp and have been looking at a lot of Windows R installs and there are some wrinkles about R_LIBS_USER. On a clean Win7 or Win8 system, with R-3.0.1, we see the user library for packages defaulting to $HOME/R/win-l

Re: [R] 2SLS / TSLS / SEM non-linear

2013-06-29 Thread Paul Johnson
Please consider using the R package systemfit. It has existed for about 10 years, I've used it many times happily :) I've not used gmm package, I'm not criticizing it. But I have good results from systemfit. It has good documentation. "This package contains functions for fitting simultaneous sys

[R] good documentation on use of Rscript. where to find?

2012-10-18 Thread Paul Johnson
What is the correct format for the shebang line and what options are allowed or necessary along with this? I find plenty of blogs and opinions, but few authoritative answers. I want an R script to run and update packages periodically, with a cron job that launches it. What is necessary to put in

[R] premature evaluation of symbols. Is that the way to describe this problem?

2014-04-10 Thread Paul Johnson
I know, I don't have all the right words here. I've built a toy example that will illustrate the problem, you tell me the words for it. ## Paul Johnson 2014-04-10 dat <- data.frame(x = rnorm(50),y = rnorm(50)) m1 <- lm(y ~ x, dat) myRegFit <- function(model, nd) predict(m

[R] plotmath vector problem; full program enclosed

2010-07-06 Thread Paul Johnson
As usual, thanks in advance for your help, sorry if I've made an obvious mistake or overlooked a manual. ### Filename: plotMathProblem.R ### Paul Johnson July 5, 2010 ### email me sigma <- 10.0 mu <- 4.0 myx <- seq( mu - 3.5*sigma, mu+ 3.5*sigma, length.out=500) myDensity

Re: [R] how to save summary(lm) and anova (lm) in format?

2010-07-06 Thread Paul Johnson
There are R packages that can make nice R regression tables in LaTeX documents. I've used memisc and its good, there is also "apsrtable" and the old standby xtable. Also I use my own function "outreg", but that's just a 'not invented here' attitude. Your problem is that you need this to go into W

Re: [R] plotmath vector problem; full program enclosed

2010-07-06 Thread Paul Johnson
On Tue, Jul 6, 2010 at 12:41 PM, Duncan Murdoch wrote: > On 06/07/2010 10:54 AM, Paul Johnson wrote: >> >> Here's another example of my plotmath whipping boy, the Normal >> distribution. >> > You want "as.expression(b1)", not "expression(b1)"

Re: [R] plotmath vector problem; full program enclosed

2010-07-07 Thread Paul Johnson
uot;why do b2, b3, b4 , and b5" get processed properly into plot math even though they are not expressions?? ??? pj ### Filename: plotMathProblem.R ### Paul Johnson July 7, 2010 ### email me sigma <- 10.0 mu <- 4.0 myx <- seq( mu - 3.5*sigma, mu+ 3.5*sigma, length.out=500

Re: [R] coxph and ordinal variables?

2010-09-08 Thread Paul Johnson
run it with factor() instead of ordered(). You don't want the "orthogonal polynomial" contrasts that result from ordered if you need to compare against Stata. I attach an R program that I wrote to explore ordered factors a while agol I believe this will clear everything up if you study the exampl

[R] Fast / dependable way to "stack together" data frames from a list

2010-09-08 Thread Paul Johnson
I've run this quite a few times, and the relative speed of the different approaches has never differed much. If you run this, I hope you will feel smarter, as I do! :) ## stackListItems.R ## Paul Johnson ## 2010-09-07 ## Here is a test case df1 <- data.frame(x=rnorm(100),y=rnorm(100))

Re: [R] coxph and ordinal variables?

2010-09-10 Thread Paul Johnson
u are still trying to understand what 'orthogonal polynomial' means, I suggest you run the following through. I thought it was an enlightening experience. # Paul Johnson Nov. 16, 2005 # Ordinal predictors with a small number of possible values # Here is R code and commentary about ordinal pred

Re: [R] Problems with "pdf" device using "plot" "glht" function on "multcomp" library.

2010-09-18 Thread Paul Johnson
Hi, Kenneth It is not clear if you mean that your pdf output usually works, but it does not in this special case, or that this is a first effort with pdf. The answer might depend on which is the case case. If you are just getting started, can I refer you to some lecture notes I made about saving

Re: [R] What solve() does?

2010-09-04 Thread Paul Johnson
On Wed, Sep 1, 2010 at 5:36 AM, Petar Milin wrote: > Hello! > Can anyone explain me what solve() function does: Gaussian elimination or > iterative, numeric solve? In addition, I would need both the Gaussian > elimination and iterative solution for the course. Are the two built in R? > > Thanks!

[R] Please explain "do.call" in this context, or critique to "stack this list faster"

2010-09-04 Thread Paul Johnson
x27;s the self contained working example that compares the speed of various approaches. If you send yet more ways to do this, I will add them on and then post the result to my Working Example collection. ## stackMerge.R ## Paul Johnson ## 2010-09-02 ## rbind is neat,but how to do it to a lot of

Re: [R] Save data as .pdf or .JPG

2010-09-04 Thread Paul Johnson
On Wed, Sep 1, 2010 at 7:56 AM, khush wrote: > Hi all , > > I have following script to plot some data. > > plot( c(1,1100), c(0,15), type='n', xlab='', ylab='', ylim=c(0.1,25) , > las=2) > axis (1, at = seq(0,1100,50), las =2) > axis (2, at = seq(0,25,1), las =2) >> > When I source("scrip

Re: [R] graphics: 3D regression plane

2011-04-27 Thread Paul Johnson
Hi. Comments below On Wed, Apr 27, 2011 at 2:32 AM, agent dunham wrote: > Hi, thanks, I think I've changed the previous as you told me but I'm having > this error, what does it mean? > > > model<- lm(log(v1)~log(v2)+v3, data=dat) > > newax<- expand.grid( >    v2 = seq(min(log(dat$v2)), max(log(da

Re: [R] very basic HLM question

2011-02-05 Thread Paul Johnson
2011/2/5 Sebastián Daza : > Hi everyone, > > I need to get a between-component variance (e.g. random effects Anova), but > using lmer I don't get the same results (variance component) than using > random effects Anova. I am using a database of students, clustered on > schools (there is not the same

Re: [R] different results in MASS's mca and SAS's corresp

2011-02-05 Thread Paul Johnson
On Sat, Feb 5, 2011 at 9:19 AM, David Winsemius wrote: > > On Feb 4, 2011, at 7:06 PM, Gong-Yi Liao wrote: > >> Dear list: >> >>  I have tried MASS's mca function and SAS's PROC corresp on the >>  farms data (included in MASS, also used as mca's example), the >>  results are different: >> >>  R: m

Re: [R] boostrap an nls regression

2011-02-05 Thread Paul Johnson
Hello! On Thu, Feb 3, 2011 at 6:27 AM, m234 wrote: > > II functional response for 2 data sets: > > nls(eaten~(a*suppl)/(1+a*h*suppl) > > where eaten is the number of prey eaten by a predator and suppl is the > number of prey initially supplied to the same predator. > > I have parameter estimates

Re: [R] fit.mult.impute() in Hmisc

2011-08-13 Thread Paul Johnson
On Thu, Mar 31, 2011 at 2:56 PM, Yuelin Li wrote: > I tried multiple imputation with aregImpute() and > fit.mult.impute() in Hmisc 3.8-3 (June 2010) and R-2.12.1. > > The warning message below suggests that summary(f) of > fit.mult.impute() would only use the last imputed data set. > Thus, the who

[R] seeking advice about rounding error and %%

2011-08-13 Thread Paul Johnson
A client came into our consulting center with some data that had been damaged by somebody who opened it in MS Excel. The columns were supposed to be integer valued, 0 through 5, but some of the values were mysteriously damaged. There were scores like 1.18329322 and such in there. Until he tracks

[R] memory usage benefit from "anonymous" variable constructions.

2012-06-03 Thread Paul Johnson
This is an "I was just wondering" question. When the package "dataframe" was announced, the author claimed to reduce the number of times a data frame was copied, I started to wonder if I should care about this in my projects. Has anybody written a general guide for how to write R code that doesn'

Re: [R] Partial R-square in multiple linear regression

2012-06-03 Thread Paul Johnson
On Fri, Jun 1, 2012 at 2:05 PM, Jin Choi wrote: > Hello, > > I am trying to obtain the partial r-square values (r^2 or R2) for > individual predictors of an outcome variable in multiple linear > regression. I am using the 'lm' function to calculate the beta > coefficients, however, I would like to

[R] non ascill characters in plots. no alternative but plotmath?

2012-06-06 Thread Paul Johnson
A student entered some data with text characters like epsilon and alpha. On her Windows system, the Greek letters did not display properly in a plot. There were some ordinary ASCII instead. I asked her to send me the code so I could test. For me, the plot looks ok on the screen. Format1 <- c(3

Re: [R] EM algorithm to find MLE of coeff in mixed effects model

2012-07-03 Thread Paul Johnson
On Tue, Jul 3, 2012 at 12:41 PM, jimmycloud wrote: > I have a general question about coefficients estimation of the mixed model. > I have 2 ideas for you. 1. Fit with lme4 package, using the lmer function. That's what it is for. 2. If you really want to write your own EM algorithm, I don't feel

[R] Question re the plotrix package

2011-07-27 Thread Paul Johnson
Dear list, I am using the  clock24.plot command in this excellent package to plot animal activity data. Does anyone know if both symbols and a line can be plotted on the same plot to show both raw data (symbols) and a line (describing a statistical model of the pattern) ? Or if more than one

Re: [R] complexity of operations in R

2012-07-19 Thread Paul Johnson
On Thu, Jul 19, 2012 at 11:11 AM, Bert Gunter wrote: > Hadley et. al: > > Indeed. And using a loop is a poor way to do it anyway. > > v <- as.list(rep(FALSE,dotot)) > > is way faster. > > -- Bert > Its not entirely clear to me what we are supposed to conclude about this. I can confirm Bert's cla

[R] device "mismatch", coordinates trouble with X11 and pdf devices

2012-08-10 Thread Paul Johnson
hed base packages: [1] stats graphics grDevices utils datasets methods base ## Paul Johnson ## 2012-08-10 ## ## I've got trouble with a mis-match between screen and pdf devices. ## Please run this and tell me if the point z's "marker" is on the ## intersection of the 2 c

[R] shade overlapping portions of circles (or other shapes)

2012-08-15 Thread Paul Johnson
I'm making some illustrations and it would be convenient to automatically shade the overlapping portions of circles. These illustrations are for Social Choice theory, a field in political science and economics. I've wrestled together some examples so you can see what I mean, but have not mastered

Re: [R] Models with ordered and unordered factors

2011-11-15 Thread Paul Johnson
On Tue, Nov 15, 2011 at 9:00 AM, Catarina Miranda wrote: > Hello; > > I am having a problems with the interpretation of models using ordered or > unordered predictors. > I am running models in lmer but I will try to give a simplified example > data set using lm. > Both in the example and in my rea

[R] how "big" (in RAM and/or disk storage) is each of these objects in a list?

2011-11-26 Thread Paul Johnson
Greetings, friends (and others :) ) We generated a bunch of results and saved them in an RData file. We can open, use, all is well, except that the size of the saved file is quite a bit larger than we expected. I suspect there's something floating about in there that one of the packages we are us

[R] fundamental guide to use of numerical optimizers?

2011-12-15 Thread Paul Johnson
I was in a presentation of optimizations fitted with both MPlus and SAS yesterday. In a batch of 1000 bootstrap samples, between 300 and 400 of the estimations did not converge. The authors spoke as if this were the ordinary cost of doing business, and pointed to some publications in which the no

[R] pls help to print out first row of terms(model) output in example program

2011-12-19 Thread Paul Johnson
x1)1 0 poly(x2, 2) 0 1 attr(,"term.labels") [1] "log(10 + x1)" "poly(x2, 2)" [snip] In my working example code below , I need the help where I have "##fix me fix me## ##Paul Johnson ## 2011-12-19 ## mcDiagnose.R lmAuxiliary

[R] 3d plotting alternatives. I like persp, but regret the lack of plotmath.

2011-12-29 Thread Paul Johnson
I have been making simple functions to display regressions in a new package called "rockchalk". For 3d illustrations, my functions use persp, and I've grown to like working with it. As an example of the kind of things I like to do, you might consult my lecture on multicollinearity, which is by fa

[R] How to properly re-set a saved seed? I've got the answer, but no explanation

2012-01-06 Thread Paul Johnson
including L'Ecuyer streams. The puzzle is this comment in ?Random: "‘set.seed’ is the recommended way to specify seeds." What I did not understand before, and can't make sense of now, is that set.seed does not "re-set" a saved seed. Here's my working example: ##

[R] fix and edit don't work: unable to open X Input Method->segfault

2012-01-08 Thread Paul Johnson
I can't run fix() or edit() anymore. Did I break my system? I'm running Debian Linux with R-2.14.1. As far as I can tell, the R packages came from Debian's testing "wheezy" repository. I would like to know if users on other types of systems see the same problem. If no, then, obviously, it is a De

Re: [R] Testing for arguments in a function

2011-09-28 Thread Paul Johnson
On Mon, Sep 26, 2011 at 2:39 PM, Gene Leynes wrote: > I don't understand how this function can subset by i when i is missing > > ## My function: > myfun = function(vec, i){ >    ret = vec[i] >    ret > } > > ## My data: > i = 10 > vec = 1:100 > > ## Expected input and behavior: > myfun(vec, i)

Re: [R] Testing for arguments in a function

2011-09-30 Thread Paul Johnson
Just for the record, following Bill Dunlap's advice, I think this is the best answer to the question as originally posed is. myfun <- function(vec, i=stop("'i' must be supplied")){ vec[i] } > myfun(1:40,10) [1] 10 > myfun(1:10) Error in myfun(1:10) : 'i' must be supplied > -- Paul E. Johnson P

Re: [R] Running a GMM Estimation on dynamic Panel Model using plm-Package

2011-10-05 Thread Paul Johnson
On Sun, Jun 12, 2011 at 2:43 PM, bstudent wrote: > Hello, > > although I searched for a solution related to my problem I didn´t find one, > yet. My skills in R aren´t very large, however. > For my Diploma thesis I need to run a GMM estimation on a dynamic panel > model using the "pgmm" - function

Re: [R] Tinn-R

2011-10-05 Thread Paul Johnson
On Tue, Oct 4, 2011 at 1:25 PM, Charles McClure wrote: > I am new to R and have recently tried Tinn-R with very mixed and unexpected > results.  Can you point me to a Tinn-R tutorial on the web or a decent > reference book? > In my experience, TINN-R does not work so well, and most new users are

[R] multi-platform equivalent of x11() ?

2012-03-06 Thread Paul Johnson
I want to write an R help example that throws up 2 graphs in separate windows, for comparison. In Linux I plot one, then run x11() to spawn a new on-screen device. Is there some generic equivalent so I can write an example that will work for Windows and Mac users as well? If there is none, don'

Re: [R] simulate an gradually increase of the number of subjects based on two variables

2012-03-13 Thread Paul Johnson
Suggestion below: On Tue, Mar 13, 2012 at 1:24 PM, guillaume chaumet wrote: > I omit to precise that I already try to generate data based on the mean and > sd of two variables. > > x=rnorm(20,1,5)+1:20 > > y=rnorm(20,1,7)+41:60 > > simu<-function(x,y,n) { >    simu=vector("list",length=n) > >    

Re: [R] beginner's loop issue

2012-03-13 Thread Paul Johnson
On Tue, Mar 13, 2012 at 11:27 AM, aledanda wrote: > Dear All, > > I hope you don't mind helping me with this small issue. I haven't been using > R in years and I'm trying to fill in a matrix > with the output of a function (I'm probably using the Matlab logic here and > it's not working). > Here i

[R] [R-pkgs] rockchalk_1.5.4 posted

2012-04-10 Thread Paul Johnson
Greetings: rockchalk is a collection of functions to facilitate presentation of regression models. It includes some functions that I have been circulating for quite some time (such as "outreg") as well as several others. The main aim is to allow people who do not understand very much R to surviv

Re: [R] question on model.matrix

2012-01-30 Thread Paul Johnson
Greetings On Sat, Jan 28, 2012 at 2:43 PM, Daniel Negusse wrote: >> >> >> while reading some tutorials, i came across this and i am stuck. i want to >> understand it and would appreciate if anyone can tell me. >> >> design <- model.matrix(~ -1+factor(c(1,1,2,2,3,3))) >> >> can someone break dow

[R] replacing characters in matrix. substitute, delayedAssign, huh?

2012-01-30 Thread Paul Johnson
A user question today has me stumped. Can you advise me, please? User wants a matrix that has some numbers, some variables, possibly even some function names. So that has to be a character matrix. Consider: > BM <- matrix("0.1", 5, 5) Use data.entry(BM) or similar to set some to more abstract

Re: [R] replacing characters in matrix. substitute, delayedAssign, huh?

2012-01-30 Thread Paul Johnson
Henrik's proposal works well, so far. Thanks very much. I could not have figured that out (without much more suffering). Here's the working example in case future googlers find their way to this thread. ## Paul Johnson ## 2012-01-30 ## Special thanks to r-help email list co

[R] predictOMatic for regression. Please try and advise me

2012-04-20 Thread Paul Johnson
, please try out the following and let me know how its use could be enhanced, or what other features you might want. I know folks are busy, so to save you the trouble of actually running the code, I also paste in a session demonstrating one run through. Here's the code: ##Paul Johnson ## 2

Re: [R] Solve an ordinary or generalized eigenvalue problem in R?

2012-04-20 Thread Paul Johnson
On Fri, Apr 20, 2012 at 2:18 PM, Jonathan Greenberg wrote: > Ok, I figured out a solution and I'd like to get some feedback on this from > the R-helpers as to how I could modify the following to be "package > friendly" -- the main thing I'm worried about is how to dynamically set the There's doc

[R] what folder to run write_PACKAGES in?

2012-05-08 Thread Paul Johnson
I set up a local repo for testing packages. My packages are not showing up from the repository when viewed by Linux clients. I suspect this is a web administrator/firewall issue, but it could be I created the repo wrongly. I am supposed to run write_PACKAGES separately in each R-version folder. Ri

  1   2   >