Re: [ESS] [EXTERNAL] Re: How to Duplicate Previous Functionality/Workflow

2023-09-26 Thread Tyler Smith via ESS-help
On Tue, Sep 26, 2023, at 2:38 PM, Bassett Jr,Roland L via ESS-help wrote:
> Thanks to everyone for their responses - you've definitely helped with 
> most of my questions.  One still remains, though:
>
> How can I customize the weaver and the exporter so that it doesn't ask 
> each time?  It seems as though there should be a way to customize each 
> of these, but I can't figure out what it is.

I agree, it does seem like this ought to be customizable! I looked into the 
code a bit, and from what I can see there's no option to change it, beyond 
over-writing the existing functions.

- Tyler




>
> Roland Bassett
> Principal Biostatistician
> Department of Biostatistics - Unit 1411
> Faculty Center Tower FCT4.6071
> The University of Texas M. D. Anderson Cancer Center
> P.O. Box 301402
> Houston, TX 77230
>
> Phone: 713-563-4272
> Fax: 713-563-4242
> Email: rlbas...@mdanderson.org
>
> -Original Message-
> From: ESS-help  On Behalf Of Tyler 
> Smith via ESS-help
> Sent: Saturday, September 23, 2023 10:38 AM
> To: Stephen J. Eglen 
> Cc: ESS-help 
> Subject: [EXTERNAL] Re: [ESS] How to Duplicate Previous 
> Functionality/Workflow
>
> THIS EMAIL IS A PHISHING RISK
>  Do you trust the sender?
> The email address is: ess-help-boun...@r-project.org
> While this email has passed our filters, we need you to review with 
> caution before taking any action.
> If the email looks at all suspicious, click the Report a Phish 
> button.
>
> On Fri, Sep 22, 2023, at 2:04 AM, Stephen J. Eglen wrote:
>>> (You probably didn't do this, because Docview isn't great for pdfs.
>>> The now abandoned package pdf-tools was a great option for reading
>>> pdfs inside Emacs).
>>
>> just to add a couple of comments:
>>
>> 1. pdf-tools was forked about 1-2 years ago, and now active at:
>>
>> https://urldefense.com/v3/__https://github.com/vedang/pdf-tools__;!!Pf
>> beBCCAmug!hJB8MImjmlLQXcAB-LAswXJZi7hbkrS4q5t30Qi2hgkPBMiYQFEMW4gXbr-6
>> hVAcqLnnAh9bX0OFHLbHRmIz8Hs$
>>
>> It can be a bit fussy to install compared to most Emacs packages,
>> because of dependencies and the binaries it creates.  However, I like
>> it and use it regularly.
>>
>
> Thanks, that's great news!  pdf-tools was my preferred pdf viewer when 
> it was active. I'll definitely check out the new fork
>
> ty
>
> __
> ESS-help@r-project.org mailing list
> https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/ess-help__;!!PfbeBCCAmug!hJB8MImjmlLQXcAB-LAswXJZi7hbkrS4q5t30Qi2hgkPBMiYQFEMW4gXbr-6hVAcqLnnAh9bX0OFHLbH1kUWylg$
>
> The information contained in this e-mail message may be ...{{dropped:11}}
>
> __
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] [EXTERNAL] Re: How to Duplicate Previous Functionality/Workflow

2023-09-26 Thread Bassett Jr,Roland L via ESS-help
Thanks to everyone for their responses - you've definitely helped with most of 
my questions.  One still remains, though:

How can I customize the weaver and the exporter so that it doesn't ask each 
time?  It seems as though there should be a way to customize each of these, but 
I can't figure out what it is.

Roland Bassett
Principal Biostatistician
Department of Biostatistics - Unit 1411
Faculty Center Tower FCT4.6071
The University of Texas M. D. Anderson Cancer Center
P.O. Box 301402
Houston, TX 77230

Phone: 713-563-4272
Fax: 713-563-4242
Email: rlbas...@mdanderson.org

-Original Message-
From: ESS-help  On Behalf Of Tyler Smith via 
ESS-help
Sent: Saturday, September 23, 2023 10:38 AM
To: Stephen J. Eglen 
Cc: ESS-help 
Subject: [EXTERNAL] Re: [ESS] How to Duplicate Previous Functionality/Workflow

THIS EMAIL IS A PHISHING RISK
 Do you trust the sender?
The email address is: ess-help-boun...@r-project.org
While this email has passed our filters, we need you to review with caution 
before taking any action.
If the email looks at all suspicious, click the Report a Phish button.

On Fri, Sep 22, 2023, at 2:04 AM, Stephen J. Eglen wrote:
>> (You probably didn't do this, because Docview isn't great for pdfs.
>> The now abandoned package pdf-tools was a great option for reading
>> pdfs inside Emacs).
>
> just to add a couple of comments:
>
> 1. pdf-tools was forked about 1-2 years ago, and now active at:
>
> https://urldefense.com/v3/__https://github.com/vedang/pdf-tools__;!!Pf
> beBCCAmug!hJB8MImjmlLQXcAB-LAswXJZi7hbkrS4q5t30Qi2hgkPBMiYQFEMW4gXbr-6
> hVAcqLnnAh9bX0OFHLbHRmIz8Hs$
>
> It can be a bit fussy to install compared to most Emacs packages,
> because of dependencies and the binaries it creates.  However, I like
> it and use it regularly.
>

Thanks, that's great news!  pdf-tools was my preferred pdf viewer when it was 
active. I'll definitely check out the new fork

ty

__
ESS-help@r-project.org mailing list
https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/ess-help__;!!PfbeBCCAmug!hJB8MImjmlLQXcAB-LAswXJZi7hbkrS4q5t30Qi2hgkPBMiYQFEMW4gXbr-6hVAcqLnnAh9bX0OFHLbH1kUWylg$

The information contained in this e-mail message may be ...{{dropped:11}}

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] Have M-x R point at the most recent version of R

2023-09-26 Thread Toby Hocking via ESS-help
I put it on the path,
Windows key -> Edit the system environment variables -> Environment
variables... -> Double click Path -> add C:\Program
Files\R\R-devel\bin\x64 or whatever

On Tue, Sep 26, 2023 at 3:07 AM Hüsing, Johannes via ESS-help
 wrote:
>
> Dear ESS-helping crowd,
> following the advice on https://r-pkgs.org/setup.html, I installed R version 
> 4.3.1 for MS Windows from CRAN.
>
> How do I communicate to ESS that a new version has been installed? I read the 
> advice on 
> https://emacs.stackexchange.com/questions/60681/ess-start-process-does-not-include-new-r-version,
>  I used the Emacs customisation dialogue to set ess-rterm-version-paths from 
> C:/Program Files/R/R-4.2.2/bin/x64/Rterm.exe to C:/Program 
> Files/R/R-4.3.1/bin/x64/Rterm.exe. After that, the variable 
> ess-r-runner-prefixes, as well as ess-r-versions resolves to ("R-1" "R-2" 
> "R-3" "R-4" "R-5" "R-6" "R-7" "R-devel" "R-patched"), and both M-x R and M-x 
> R-newest will start R 4.2.2. The variable ess-r-versions-created resolves to 
> (R-4.2.2-64bit), as does its alias ess-r-created-runners. Neither of these is 
> customizable in the Emacs dialog.
>
> Is there a way to proceed to notify ESS about the new version installed? 
> RStudio opened a miniscule dialog window indicating that it detected 
> conflicting versions and had me choose one of them.
>
> Thanks for any hint.
>
>
>
> Dr. Johannes Hüsing
> Epidemiologie
>
> Landeskrebsregister NRW gGmbH
> Gesundheitscampus 10
> 44801 Bochum
>
>
>
> T 0234 54509-216
> F 0234 54509-499
> johannes.hues...@krebsregister.nrw.de
> www.landeskrebsregister.nrw
>
> Das Landeskrebsregister NRW online
> FACEBOOK: 
> www.facebook.com/LKR.NordrheinWestfalen
> INSTAGRAM: https://www.instagram.com/landeskrebsregister_nrw
> NEWSLETTER: https://www.landeskrebsregister.nrw/aktuelles/newsletter
>
>
> Geschäftsführer
> Dr. Andres Schützendübel
> Vorsitzender der Gesellschafterversammlung
> Staatssekretär Matthias Heidmeier
> Sitz der Gesellschaft
> Bochum
> Registergericht
> Amtsgericht Bochum
> HRB 17715
>
> HINWEIS: Diese Nachricht ist nur für den Adressaten bestimmt. Es ist nicht 
> erlaubt, diese Nachricht zu kopieren oder Dritten zugänglich zu machen. 
> Sollten Sie irrtümlich diese Nachricht erhalten haben, bitte ich um Ihre 
> Mitteilung per E-Mail oder unter der oben angegebenen Telefonnummer.
>
> [[alternative HTML version deleted]]
>
> __
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] car::deltaMethod() fails when a particular combination of categorical variables is not present

2023-09-26 Thread John Fox

Dear Michael,

My previous response was inaccurate: First, linearHypothesis() *is* able 
to accommodate aliased coefficients by setting the argument singular.ok 
= TRUE:


> linearHypothesis(minimal_model, "bt2 + csent + bt2:csent = 0",
+  singular.ok=TRUE)

Linear hypothesis test:
bt2  + csent  + bt2:csent = 0

Model 1: restricted model
Model 2: a ~ b * c

  Res.DfRSS Df Sum of Sq  F Pr(>F)
1 16 9392.1
2 15 9266.4  1125.67 0.2034 0.6584

Moreover, when there is an empty cell, this F-test is (for a reason that 
I haven't worked out, but is almost surely due to how the rank-deficient 
model is parametrized) *not* equivalent to the t-test for the 
corresponding coefficient in the raveled version of the two factors:


> df$bc <- factor(with(df, paste(b, c, sep=":")))
> m <- lm(a ~ bc, data=df)
> summary(m)

Call:
lm(formula = a ~ bc, data = df)

Residuals:
Min  1Q  Median  3Q Max
-57.455 -11.750   0.439  14.011  37.545

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)20.50  17.57   1.166   0.2617
bct1:unsent37.50  24.85   1.509   0.1521
bct2:other 32.00  24.85   1.287   0.2174
bct2:sent  17.17  22.69   0.757   0.4610  <<< cf. F = 0.2034, p 
= 0.6584

bct2:unsent38.95  19.11   2.039   0.0595

Residual standard error: 24.85 on 15 degrees of freedom
Multiple R-squared:  0.2613,Adjusted R-squared:  0.06437
F-statistic: 1.327 on 4 and 15 DF,  p-value: 0.3052

In the full-rank case, however, what I said is correct -- that is, the 
F-test for the 1 df hypothesis on the three coefficients is equivalent 
to the t-test for the corresponding coefficient when the two factors are 
raveled:


> linearHypothesis(minimal_model_fixed, "bt2 + csent + bt2:csent = 0")

Linear hypothesis test:
bt2  + csent  + bt2:csent = 0

Model 1: restricted model
Model 2: a ~ b * c

  Res.DfRSS Df Sum of Sq  F Pr(>F)
1 15 9714.5
2 14 9194.4  1520.08 0.7919 0.3886

> df_fixed$bc <- factor(with(df_fixed, paste(b, c, sep=":")))
> m <- lm(a ~ bc, data=df_fixed)
> summary(m)

Call:
lm(formula = a ~ bc, data = df_fixed)

Residuals:
Min  1Q  Median  3Q Max
-57.455 -11.750   0.167  14.011  37.545

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)   64.000 25.627   2.497   0.0256
bct1:sent-43.500 31.387  -1.386   0.1874
bct1:unsent  -12.000 36.242  -0.331   0.7455
bct2:other   -11.500 31.387  -0.366   0.7195
bct2:sent-26.333 29.591  -0.890   0.3886 << cf.
bct2:unsent   -4.545 26.767  -0.170   0.8676

Residual standard error: 25.63 on 14 degrees of freedom
Multiple R-squared:  0.2671,Adjusted R-squared:  0.005328
F-statistic:  1.02 on 5 and 14 DF,  p-value: 0.4425

So, to summarize:

(1) You can use linearHypothesis() with singular.ok=TRUE to test the 
hypothesis that you specified, though I suspect that this hypothesis 
probably isn't testing what you think in the rank-deficient case. I 
suspect that the hypothesis that you want to test is obtained by 
raveling the two factors.


(2) There is no reason to use deltaMethod() for a linear hypothesis, but 
there is also no intrinsic reason that deltaMethod() shouldn't be able 
to handle a rank-deficient model. We'll probably fix that.


My apologies for the confusion,
 John

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://www.john-fox.ca/

On 2023-09-26 9:49 a.m., John Fox wrote:

Caution: External email.


Dear Michael,

You're testing a linear hypothesis, so there's no need to use the delta
method, but the linearHypothesis() function in the car package also
fails in your case:

 > linearHypothesis(minimal_model, "bt2 + csent + bt2:csent = 0")
Error in linearHypothesis.lm(minimal_model, "bt2 + csent + bt2:csent = 
0") :

there are aliased coefficients in the model.

One work-around is to ravel the two factors into a single factor with 5
levels:

 > df$bc <- factor(with(df, paste(b, c, sep=":")))
 > df$bc
  [1] t2:unsent t2:unsent t2:unsent t2:unsent t2:sent   t2:unsent
  [7] t2:unsent t1:sent   t2:unsent t2:unsent t2:other  t2:unsent
[13] t1:unsent t1:sent   t2:unsent t2:other  t1:unsent t2:sent
[19] t2:sent   t2:unsent
Levels: t1:sent t1:unsent t2:other t2:sent t2:unsent

 > m <- lm(a ~ bc, data=df)
 > summary(m)

Call:
lm(formula = a ~ bc, data = df)

Residuals:
     Min  1Q  Median  3Q Max
-57.455 -11.750   0.439  14.011  37.545

Coefficients:
     Estimate Std. Error t value Pr(>|t|)
(Intercept)    20.50  17.57   1.166   0.2617
bct1:unsent    37.50  24.85   1.509   0.1521
bct2:other 32.00  24.85   1.287   0.2174
bct2:sent  17.17  22.69   0.757   0.4610
bct2:unsent    38.95  19.11   2.039   0.0595

Residual standard error: 24.85 on 15 degrees of freedom
Multiple R-squared:  0.2613,    Adjusted R-squared:  0.06437
F-statistic: 1.327 on 4 and 15 DF,  p-value: 0.3052

Then the hypothesis is tested 

Re: [R] data.table installation on intel macOS Ventura 13.6

2023-09-26 Thread Carlos Ortega
Hi,

This is the Makevars I used to compile sucessfully the latest version of
data.table in a x86_64 machine.

#--
#--- https://github.com/Rdatatable/data.table/wiki/Installation
#-
LOC = /usr/local/gfortran
CC=$(LOC)/bin/gcc -fopenmp
CXX=$(LOC)/bin/g++ -fopenmp
CXX11 = $(LOC)/bin/g++ -fopenmp # for fst package

CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib
CPPFLAGS=-I$(LOC)/include
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
#--

I had to install "gfortran" which has a link in that installation page.
Having "gfortran" was key to make it run multithread.

Thanks,
Carlos.

On Tue, Sep 26, 2023 at 11:49 AM Naresh Gurbuxani <
naresh_gurbux...@hotmail.com> wrote:

> > Sys.info()
>
>sysname
>
>   "Darwin"
>
>release
>
>   "22.6.0"
>
>version
> "Darwin Kernel Version 22.6.0: Fri Sep 15 13:39:52 PDT 2023;
> root:xnu-8796.141.3.700.8~1/RELEASE_X86_64"
>
> nodename
>
>  [deleted]
>
>machine
>
>   "x86_64"
>
>  login
>
>  [deleted]
>
>   user
>
>  [deleted]
>
> effective_user
>
>  [deleted]
>
> My Makevars file:
> CPPFLAGS += -Xclang -fopenmp
> LDFLAGS += -lomp
>
> Using brew, I installed libomp
>
> data.table is not installed on my machine.  In fresh R session:
> > install.packages("data.table", repos = "https://cran.r-project.org;)
> Installing package into ‘/usr/local/lib/R/4.3/site-library’
> (as ‘lib’ is unspecified)
> trying URL '
> https://cran.r-project.org/src/contrib/data.table_1.14.8.tar.gz'
> Content type 'application/x-gzip' length 5338582 bytes (5.1 MB)
> ==
> downloaded 5.1 MB
>
> * installing *source* package ‘data.table’ ...
> ** package ‘data.table’ successfully unpacked and MD5 sums checked
> ** using staged installation
> zlib 1.2.11 is available ok
> *** OpenMP not supported! data.table uses OpenMP to automatically
> ***   parallelize operations like sorting, grouping, file reading, etc.
> *** For details on how to install the necessary toolchains on your OS see:
> ***   https://github.com/Rdatatable/data.table/wiki/Installation
> *** Continuing installation without OpenMP support...
> ** libs
> using C compiler: ‘Homebrew clang version 17.0.1’
> using SDK: ‘’
> clang -I"/usr/local/Cellar/r/4.3.1/lib/R/include" -DNDEBUG
>  -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include
> -I/usr/local/opt/xz/include -I/usr/local/include -Xclang -fopenmp-fPIC
> -g -O2  -c assign.c -o assign.o
> [several lines deleted]
> clang -dynamiclib -Wl,-headerpad_max_install_names -undefined
> dynamic_lookup -single_module -multiply_defined suppress
> -L/usr/local/Cellar/r/4.3.1/lib/R/lib -L/usr/local/opt/gettext/lib
> -L/usr/local/opt/readline/lib -L/usr/local/opt/xz/lib -L/usr/local/lib
> -lomp -o data.table.so assign.o between.o bmerge.o chmatch.o cj.o
> coalesce.o dogroups.o fastmean.o fcast.o fifelse.o fmelt.o forder.o frank.o
> fread.o freadR.o froll.o frollR.o frolladaptive.o fsort.o fwrite.o
> fwriteR.o gsumm.o ijoin.o init.o inrange.o nafill.o nqrecreateindices.o
> openmp-utils.o quickselect.o rbindlist.o reorder.o shift.o snprintf.o
> subset.o transpose.o types.o uniqlist.o utils.o vecseq.o wrappers.o -lz
> -L/usr/local/Cellar/r/4.3.1/lib/R/lib -lR -lintl -Wl,-framework
> -Wl,CoreFoundation
> ld: warning: -single_module is obsolete
> ld: warning: -multiply_defined is obsolete
> ld: warning: -single_module is obsolete
> ld: warning: -multiply_defined is obsolete
> ld: library 'omp' not found
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
> make: *** [data.table.so] Error 1
> ERROR: compilation failed for package ‘data.table’
> * removing ‘/usr/local/lib/R/4.3/site-library/data.table’
>
> The downloaded source packages are in
>
> ‘/private/var/folders/97/5377j5_d207fshvjz_pz7szwgn/T/RtmpjZgIo0/downloaded_packages’
> Warning message:
> In install.packages("data.table", repos = "https://cran.r-project.org;) :
>   installation of package ‘data.table’ had non-zero exit status
>
> I delete above two lines from my Makevars fiie, which is now empty.  Now
> reinstall data.table.
>
> > install.packages("data.table", repos = "https://cran.r-project.org;)
> Installing package into ‘/usr/local/lib/R/4.3/site-library’
> (as ‘lib’ is unspecified)
> trying URL '
> https://cran.r-project.org/src/contrib/data.table_1.14.8.tar.gz'
> Content type 'application/x-gzip' length 5338582 bytes (5.1 MB)
> ==
> downloaded 5.1 MB
>
> * installing *source* package ‘data.table’ ...
> ** package ‘data.table’ successfully unpacked and MD5 sums checked
> 

Re: [R] car::deltaMethod() fails when a particular combination of categorical variables is not present

2023-09-26 Thread John Fox

Dear Michael,

You're testing a linear hypothesis, so there's no need to use the delta 
method, but the linearHypothesis() function in the car package also 
fails in your case:


> linearHypothesis(minimal_model, "bt2 + csent + bt2:csent = 0")
Error in linearHypothesis.lm(minimal_model, "bt2 + csent + bt2:csent = 0") :
there are aliased coefficients in the model.

One work-around is to ravel the two factors into a single factor with 5 
levels:


> df$bc <- factor(with(df, paste(b, c, sep=":")))
> df$bc
 [1] t2:unsent t2:unsent t2:unsent t2:unsent t2:sent   t2:unsent
 [7] t2:unsent t1:sent   t2:unsent t2:unsent t2:other  t2:unsent
[13] t1:unsent t1:sent   t2:unsent t2:other  t1:unsent t2:sent
[19] t2:sent   t2:unsent
Levels: t1:sent t1:unsent t2:other t2:sent t2:unsent

> m <- lm(a ~ bc, data=df)
> summary(m)

Call:
lm(formula = a ~ bc, data = df)

Residuals:
Min  1Q  Median  3Q Max
-57.455 -11.750   0.439  14.011  37.545

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)20.50  17.57   1.166   0.2617
bct1:unsent37.50  24.85   1.509   0.1521
bct2:other 32.00  24.85   1.287   0.2174
bct2:sent  17.17  22.69   0.757   0.4610
bct2:unsent38.95  19.11   2.039   0.0595

Residual standard error: 24.85 on 15 degrees of freedom
Multiple R-squared:  0.2613,Adjusted R-squared:  0.06437
F-statistic: 1.327 on 4 and 15 DF,  p-value: 0.3052

Then the hypothesis is tested directly by the t-value for the 
coefficient bct2:sent.


I hope that this helps,
 John

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://www.john-fox.ca/

On 2023-09-26 1:12 a.m., Michael Cohn wrote:

Caution: External email.


I'm running a linear regression with two categorical predictors and their
interaction. One combination of levels does not occur in the data, and as
expected, no parameter is estimated for it. I now want to significance test
a particular combination of levels that does occur in the data (ie, I want
to get a confidence interval for the total prediction at given levels of
each variable).

In the past I've done this using car::deltaMethod() but in this dataset
that does not work, as shown in the example below: The regression model
gives the expected output, but deltaMethod() gives this error:

error in t(gd) %*% vcov. : non-conformable arguments

I believe this is because there is no parameter estimate for when the
predictors have the values 't1' and 'other'. In the df_fixed dataframe,
putting one person into that combination of categories causes deltaMethod()
to work as expected.

I don't know of any theoretical reason that missing one interaction
parameter estimate should prevent getting a confidence interval for a
different combination of predictors. Is there a way to use deltaMethod() or
some other function to do this without changing my data?

Thank you,

- Michael Cohn
Vote Rev (http://voterev.org)


Demonstration:
--

library(car)
# create dataset with outcome and two categorical predictors
outcomes <- c(91,2,60,53,38,78,48,33,97,41,64,84,64,8,66,41,52,18,57,34)
persontype <-
c("t2","t2","t2","t2","t2","t2","t2","t1","t2","t2","t2","t2","t1","t1","t2","t2","t1","t2","t2","t2")
arm_letter <-
c("unsent","unsent","unsent","unsent","sent","unsent","unsent","sent","unsent","unsent","other","unsent","unsent","sent","unsent","other","unsent","sent","sent","unsent")
df <- data.frame(a = outcomes, b=persontype, c=arm_letter)

# note: there are no records with the combination 't1' + 'other'
table(df$b,df$c)


#regression works as expected
minimal_formula <- formula("a ~ b*c")
minimal_model <- lm(minimal_formula, data=df)
summary(minimal_model)

#use deltaMethod() to get a prediction for individuals with the combination
'b2' and 'sent'
# deltaMethod() fails with "error in t(gd) %*% vcov. : non-conformable
arguments."
deltaMethod(minimal_model, "bt2 + csent + `bt2:csent`", rhs=0)

# duplicate the dataset and change one record to be in the previously empty
cell
df_fixed <- df
df_fixed[c(13),"c"] <- 'other'
table(df_fixed$b,df_fixed$c)

#deltaMethod() now works
minimal_model_fixed <- lm(minimal_formula, data=df_fixed)
deltaMethod(minimal_model_fixed, "bt2 + csent + `bt2:csent`", rhs=0)

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] RQuantLib installation problem

2023-09-26 Thread Naresh Gurbuxani
Updating to latest version of R and reinstalling RQuantLib worked.  

Thanks

> On Sep 24, 2023, at 5:29 PM, David Winsemius  wrote:
> 
> 
> On 9/24/23 08:23, Ivan Krylov wrote:
>> On Sun, 24 Sep 2023 02:19:20 +
>> Naresh Gurbuxani  wrote:
>> 
 install.packages("RQuantLib", repos = "https://cran.r-project.org;)
>>> Installing package into ‘/usr/local/lib/R/4.1/site-library’
>>> (as ‘lib’ is unspecified)
>>> trying URL
>>> 'https://cran.r-project.org/src/contrib/RQuantLib_0.4.17.tar.gz'
> 
> 
> Ivan is undoubtedly more knowledgeable on these matters than I, but I noticed 
> that you are trying to install the current version of RQuantLib into a 
> library that appears associated with a significantly older version of R than 
> is current the current version. (And I second the advice that this is a 
> question properly addressed to the R_SIG-mac mailing list but only with a 
> much better description of version of your setup and how R was installed. You 
> might want to install RQuantLib for a time frame that matched R 4.1.x. The 
> archive is here:
> 
> https://cran.r-project.org/src/contrib/00Archive/RQuantLib/
> 
> You may also want to set the compile flags so that R can find your version of 
> gfortran. That can be done within install.packages but most experts would 
> prefer that you do it from a system terminal session with $ R CMD INSTALL. 
> You can find details at the r help page `
> 
> ?INSTALL -- David
> 
>>  
>>> dyld[29996]: Library not loaded:
>>> /usr/local/opt/gcc/lib/gcc/11/libgfortran.5.dylib
>>> Referenced from: <383F3774-06DE-3792-AA2C-C9D6B37A2D89>
>>> /usr/local/Cellar/r/4.1.2/lib/R/lib/libR.dylib
>> So you're installing source packages into a Homebrew-built R, and they
>> fail to load after being compiled?
>> 
>> If you don't get an answer here, try r-sig-...@r-project.org or
>> .
>> 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] save() and load(): *prefer* saveRDS() and readRDS()

2023-09-26 Thread AbouEl-Makarim Aboueissa
Hi Martin: good morning

Thank you very much for your detailed explanation. Got it now.


With many thanks
Abou


On Tue, Sep 26, 2023, 3:24 AM Martin Maechler 
wrote:

> > Jeff Newmiller via R-help
> > on Mon, 25 Sep 2023 18:46:02 -0700 writes:
>
> > You never created any object in R called irisdataTest. Objects in
> the global environment have names that are unrelated to the names of files
> on disk.
> > The load function modifies an environment to create a variable named
> as it was named in the environment from which it was saved. Thus, you
> cannot simply load an object that was saved with one name into an object
> named something else. It is possible to create a new environment to put the
> loaded objects into, but I wouldn't recommend trying to explain how to do
> that to a beginner.  Rather, I would instead recommend using saveRDS and
> readRDS instead to save/load exactly one object at a time without storing
> the object name.
>
> > saveRDS( mtcars, "my_mtcars.rds" )
> > new_obj <- readRDS( "my_mtcars.rds" )
>
> > I would also guide them to never save their environment when
> prompted by R... the .RData file this creates will remember mistakes made
> in previous sessions making troubleshooting very difficult later. Instead
> they should focus on making a top-to-bottom script that has all their
> analysis steps so they can start from scratch.
>
> Yes!
>
> And just re-iterating what Jeff mentioned above:
> Notably when teaching, the use of  saveRDS()  and  readRDS()
> should be emphasized as safer / self-documenting, ...
> for the case where there's just one object to save/load.
>
> *and* you can always put several objects into a list and
> saveRDS() / readRDS() that.
>
> Note: Our pkg {sfsmisc} nowadays contains a nice utility function
> list_()  ==> help page online e.g. here
>
> https://search.r-project.org/CRAN/refmans/sfsmisc/html/list_named.html
>
> which comes were handy when you want to easily create a *named*
> list from a bunch of objects, as e.g. above to be able to nicely use
>
>   saveRDS(list_(obj1, obj2, table3, grob4, data5),
>   file = "allthings.rds")
>
> The cute utility is very simply defined as
>
> ##' list_(a, b, cc)  creates a *named* list  using the actual arguments'
> names
> list_ <- function(...) `names<-`(list(...), vapply(sys.call()[-1L],
> as.character, ""))
>
>
> > On September 25, 2023 6:23:01 PM PDT, AbouEl-Makarim Aboueissa <
> abouelmakarim1...@gmail.com> wrote:
> >> Dear ALL:
> >>
> >> I am teaching statistical packages class this semester, in R
> programing I
> >> am trying to explain the use of save() and load() with an example
> using the
> >> iris data. It seems that the save() function works, BUT when I
> tried to
> >> load the data back to R, it seems that there is a problem(s), I
> could not
> >> figure out what went wrong.
> >>
> >> Any help would be highly appreciated.
> >>
> >>
> >> I saved the iris data in my computer in the text format,
> "iris.with.head.txt
> >> ".
> >>
> >> Here are my R codes:
> >>
> >>> irisdata<-read.table("G:/iris.with.head.txt", header=T)
> >>>
> >>> head(irisdata)
> >> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
> >> 1  5.1 3.5  1.4 0.2  setosa
> >> 2  4.9 3.0  1.4 0.2  setosa
> >> 3  4.7 3.2  1.3 0.2  setosa
> >> 4  4.6 3.1  1.5 0.2  setosa
> >> 5  5.0 3.6  1.4 0.2  setosa
> >> 6  5.4 3.9  1.7 0.4  setosa
> >>
> >>
> >>
> >> *# saving the data as an .rda*
> >>
> >> save(irisdata,file="G:/irisdataTest.rda")
> >>
> >> *# load the data back to R*
> >>
> >> load(file="G:/irisdataTest.rda")
> >>
> >>
> >>> head(irisdataTest)
> >> Error in head(irisdataTest) : object 'irisdataTest' not found
> >>
> >>> irisdataTest
> >> Error: object 'irisdataTest' not found
> >>
> >>
> >>
> >> with many thanks
> >> abou
> >> __
> >>
> >>
> >> *AbouEl-Makarim Aboueissa, PhD*
> >>
> >> *Professor, Mathematics and Statistics*
> >> *Graduate Coordinator*
> >>
> >> *Department of Mathematics and Statistics*
> >> *University of Southern Maine*
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> 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.
>
> > --
> > Sent from my phone. Please excuse my brevity.
>
> > 

Re: [R] save() and load()

2023-09-26 Thread AbouEl-Makarim Aboueissa
Hi Shu: good morning

Thank you very much for your detailed explanation. Got it now.


With many thanks
Abou


On Mon, Sep 25, 2023, 9:39 PM Shu Fai Cheung 
wrote:

> Hi,
>
> You can try this:
>
> head(irisdata)
>
> Objects loaded by load() keep their names when being saved. In your
> case, it is 'irisdata'.
>
> You can also use verbose = TRUE to show the names of objects loaded:
>
> load(file = "irisdataTest.RData", verbose = TRUE)
>
> Hope this helps.
>
> Regards,
> Shu Fai
>
> On Tue, Sep 26, 2023 at 9:24 AM AbouEl-Makarim Aboueissa
>  wrote:
> >
> > Dear ALL:
> >
> > I am teaching statistical packages class this semester, in R programing I
> > am trying to explain the use of save() and load() with an example using
> the
> > iris data. It seems that the save() function works, BUT when I tried to
> > load the data back to R, it seems that there is a problem(s), I could not
> > figure out what went wrong.
> >
> > Any help would be highly appreciated.
> >
> >
> > I saved the iris data in my computer in the text format,
> "iris.with.head.txt
> > ".
> >
> > Here are my R codes:
> >
> > > irisdata<-read.table("G:/iris.with.head.txt", header=T)
> > >
> > > head(irisdata)
> >   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
> > 1  5.1 3.5  1.4 0.2  setosa
> > 2  4.9 3.0  1.4 0.2  setosa
> > 3  4.7 3.2  1.3 0.2  setosa
> > 4  4.6 3.1  1.5 0.2  setosa
> > 5  5.0 3.6  1.4 0.2  setosa
> > 6  5.4 3.9  1.7 0.4  setosa
> >
> >
> >
> > *# saving the data as an .rda*
> >
> > save(irisdata,file="G:/irisdataTest.rda")
> >
> > *# load the data back to R*
> >
> > load(file="G:/irisdataTest.rda")
> >
> >
> > >head(irisdataTest)
> > Error in head(irisdataTest) : object 'irisdataTest' not found
> >
> > > irisdataTest
> > Error: object 'irisdataTest' not found
> >
> >
> >
> > with many thanks
> > abou
> > __
> >
> >
> > *AbouEl-Makarim Aboueissa, PhD*
> >
> > *Professor, Mathematics and Statistics*
> > *Graduate Coordinator*
> >
> > *Department of Mathematics and Statistics*
> > *University of Southern Maine*
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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 -- To UNSUBSCRIBE and more, see
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] save() and load()

2023-09-26 Thread AbouEl-Makarim Aboueissa
Hi Jeff: good morning

Thank you very much for your detailed explanation. Got it now.


With many thanks
Abou


On Mon, Sep 25, 2023, 9:46 PM Jeff Newmiller 
wrote:

> You never created any object in R called irisdataTest. Objects in the
> global environment have names that are unrelated to the names of files on
> disk.
>
> The load function modifies an environment to create a variable named as it
> was named in the environment from which it was saved. Thus, you cannot
> simply load an object that was saved with one name into an object named
> something else. It is possible to create a new environment to put the
> loaded objects into, but I wouldn't recommend trying to explain how to do
> that to a beginner.  Rather, I would instead recommend using saveRDS and
> readRDS instead to save/load exactly one object at a time without storing
> the object name.
>
> saveRDS( mtcars, "my_mtcars.rds" )
> new_obj <- readRDS( "my_mtcars.rds" )
>
> I would also guide them to never save their environment when prompted by
> R... the .RData file this creates will remember mistakes made in previous
> sessions making troubleshooting very difficult later. Instead they should
> focus on making a top-to-bottom script that has all their analysis steps so
> they can start from scratch.
>
> On September 25, 2023 6:23:01 PM PDT, AbouEl-Makarim Aboueissa <
> abouelmakarim1...@gmail.com> wrote:
> >Dear ALL:
> >
> >I am teaching statistical packages class this semester, in R programing I
> >am trying to explain the use of save() and load() with an example using
> the
> >iris data. It seems that the save() function works, BUT when I tried to
> >load the data back to R, it seems that there is a problem(s), I could not
> >figure out what went wrong.
> >
> >Any help would be highly appreciated.
> >
> >
> >I saved the iris data in my computer in the text format,
> "iris.with.head.txt
> >".
> >
> >Here are my R codes:
> >
> >> irisdata<-read.table("G:/iris.with.head.txt", header=T)
> >>
> >> head(irisdata)
> >  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
> >1  5.1 3.5  1.4 0.2  setosa
> >2  4.9 3.0  1.4 0.2  setosa
> >3  4.7 3.2  1.3 0.2  setosa
> >4  4.6 3.1  1.5 0.2  setosa
> >5  5.0 3.6  1.4 0.2  setosa
> >6  5.4 3.9  1.7 0.4  setosa
> >
> >
> >
> >*# saving the data as an .rda*
> >
> >save(irisdata,file="G:/irisdataTest.rda")
> >
> >*# load the data back to R*
> >
> >load(file="G:/irisdataTest.rda")
> >
> >
> >>head(irisdataTest)
> >Error in head(irisdataTest) : object 'irisdataTest' not found
> >
> >> irisdataTest
> >Error: object 'irisdataTest' not found
> >
> >
> >
> >with many thanks
> >abou
> >__
> >
> >
> >*AbouEl-Makarim Aboueissa, PhD*
> >
> >*Professor, Mathematics and Statistics*
> >*Graduate Coordinator*
> >
> >*Department of Mathematics and Statistics*
> >*University of Southern Maine*
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >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.
>
> --
> Sent from my phone. Please excuse my brevity.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[ESS] Have M-x R point at the most recent version of R

2023-09-26 Thread Hüsing , Johannes via ESS-help
Dear ESS-helping crowd,
following the advice on https://r-pkgs.org/setup.html, I installed R version 
4.3.1 for MS Windows from CRAN.

How do I communicate to ESS that a new version has been installed? I read the 
advice on 
https://emacs.stackexchange.com/questions/60681/ess-start-process-does-not-include-new-r-version,
 I used the Emacs customisation dialogue to set ess-rterm-version-paths from 
C:/Program Files/R/R-4.2.2/bin/x64/Rterm.exe to C:/Program 
Files/R/R-4.3.1/bin/x64/Rterm.exe. After that, the variable 
ess-r-runner-prefixes, as well as ess-r-versions resolves to ("R-1" "R-2" "R-3" 
"R-4" "R-5" "R-6" "R-7" "R-devel" "R-patched"), and both M-x R and M-x R-newest 
will start R 4.2.2. The variable ess-r-versions-created resolves to 
(R-4.2.2-64bit), as does its alias ess-r-created-runners. Neither of these is 
customizable in the Emacs dialog.

Is there a way to proceed to notify ESS about the new version installed? 
RStudio opened a miniscule dialog window indicating that it detected 
conflicting versions and had me choose one of them.

Thanks for any hint.



Dr. Johannes H�sing
Epidemiologie

Landeskrebsregister NRW gGmbH
Gesundheitscampus 10
44801 Bochum



T 0234 54509-216
F 0234 54509-499
johannes.hues...@krebsregister.nrw.de
www.landeskrebsregister.nrw

Das Landeskrebsregister NRW online
FACEBOOK: 
www.facebook.com/LKR.NordrheinWestfalen
INSTAGRAM: https://www.instagram.com/landeskrebsregister_nrw
NEWSLETTER: https://www.landeskrebsregister.nrw/aktuelles/newsletter


Gesch�ftsf�hrer
Dr. Andres Sch�tzend�bel
Vorsitzender der Gesellschafterversammlung
Staatssekret�r Matthias Heidmeier
Sitz der Gesellschaft
Bochum
Registergericht
Amtsgericht Bochum
HRB 17715

HINWEIS: Diese Nachricht ist nur f�r den Adressaten bestimmt. Es ist nicht 
erlaubt, diese Nachricht zu kopieren oder Dritten zug�nglich zu machen. Sollten 
Sie irrt�mlich diese Nachricht erhalten haben, bitte ich um Ihre Mitteilung per 
E-Mail oder unter der oben angegebenen Telefonnummer.

[[alternative HTML version deleted]]

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] data.table installation on intel macOS Ventura 13.6

2023-09-26 Thread Naresh Gurbuxani
> Sys.info()

 sysname 

"Darwin" 

 release 

"22.6.0" 

 version 
"Darwin Kernel Version 22.6.0: Fri Sep 15 13:39:52 PDT 2023; 
root:xnu-8796.141.3.700.8~1/RELEASE_X86_64" 

  nodename 
 
[deleted]

 machine 

"x86_64" 

   login 

   [deleted] 

user 

   [deleted] 

  effective_user 

   [deleted]

My Makevars file:
CPPFLAGS += -Xclang -fopenmp
LDFLAGS += -lomp

Using brew, I installed libomp  

data.table is not installed on my machine.  In fresh R session:
> install.packages("data.table", repos = "https://cran.r-project.org;)
Installing package into ‘/usr/local/lib/R/4.3/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.r-project.org/src/contrib/data.table_1.14.8.tar.gz'
Content type 'application/x-gzip' length 5338582 bytes (5.1 MB)
==
downloaded 5.1 MB

* installing *source* package ‘data.table’ ...
** package ‘data.table’ successfully unpacked and MD5 sums checked
** using staged installation
zlib 1.2.11 is available ok
*** OpenMP not supported! data.table uses OpenMP to automatically
***   parallelize operations like sorting, grouping, file reading, etc.
*** For details on how to install the necessary toolchains on your OS see:
***   https://github.com/Rdatatable/data.table/wiki/Installation
*** Continuing installation without OpenMP support...
** libs
using C compiler: ‘Homebrew clang version 17.0.1’
using SDK: ‘’
clang -I"/usr/local/Cellar/r/4.3.1/lib/R/include" -DNDEBUG   
-I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include 
-I/usr/local/opt/xz/include -I/usr/local/include -Xclang -fopenmp-fPIC  -g 
-O2  -c assign.c -o assign.o
[several lines deleted]
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup 
-single_module -multiply_defined suppress -L/usr/local/Cellar/r/4.3.1/lib/R/lib 
-L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib 
-L/usr/local/opt/xz/lib -L/usr/local/lib -lomp -o data.table.so assign.o 
between.o bmerge.o chmatch.o cj.o coalesce.o dogroups.o fastmean.o fcast.o 
fifelse.o fmelt.o forder.o frank.o fread.o freadR.o froll.o frollR.o 
frolladaptive.o fsort.o fwrite.o fwriteR.o gsumm.o ijoin.o init.o inrange.o 
nafill.o nqrecreateindices.o openmp-utils.o quickselect.o rbindlist.o reorder.o 
shift.o snprintf.o subset.o transpose.o types.o uniqlist.o utils.o vecseq.o 
wrappers.o -lz -L/usr/local/Cellar/r/4.3.1/lib/R/lib -lR -lintl -Wl,-framework 
-Wl,CoreFoundation
ld: warning: -single_module is obsolete
ld: warning: -multiply_defined is obsolete
ld: warning: -single_module is obsolete
ld: warning: -multiply_defined is obsolete
ld: library 'omp' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [data.table.so] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/usr/local/lib/R/4.3/site-library/data.table’

The downloaded source packages are in

‘/private/var/folders/97/5377j5_d207fshvjz_pz7szwgn/T/RtmpjZgIo0/downloaded_packages’
Warning message:
In install.packages("data.table", repos = "https://cran.r-project.org;) :
  installation of package ‘data.table’ had non-zero exit status

I delete above two lines from my Makevars fiie, which is now empty.  Now 
reinstall data.table.

> install.packages("data.table", repos = "https://cran.r-project.org;)
Installing package into ‘/usr/local/lib/R/4.3/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.r-project.org/src/contrib/data.table_1.14.8.tar.gz'
Content type 'application/x-gzip' length 5338582 bytes (5.1 MB)
==
downloaded 5.1 MB

* 

Re: [R] save() and load(): *prefer* saveRDS() and readRDS()

2023-09-26 Thread Martin Maechler
> Jeff Newmiller via R-help 
> on Mon, 25 Sep 2023 18:46:02 -0700 writes:

> You never created any object in R called irisdataTest. Objects in the 
global environment have names that are unrelated to the names of files on disk.
> The load function modifies an environment to create a variable named as 
it was named in the environment from which it was saved. Thus, you cannot 
simply load an object that was saved with one name into an object named 
something else. It is possible to create a new environment to put the loaded 
objects into, but I wouldn't recommend trying to explain how to do that to a 
beginner.  Rather, I would instead recommend using saveRDS and readRDS instead 
to save/load exactly one object at a time without storing the object name.

> saveRDS( mtcars, "my_mtcars.rds" )
> new_obj <- readRDS( "my_mtcars.rds" )

> I would also guide them to never save their environment when prompted by 
R... the .RData file this creates will remember mistakes made in previous 
sessions making troubleshooting very difficult later. Instead they should focus 
on making a top-to-bottom script that has all their analysis steps so they can 
start from scratch.

Yes!

And just re-iterating what Jeff mentioned above:
Notably when teaching, the use of  saveRDS()  and  readRDS()
should be emphasized as safer / self-documenting, ...
for the case where there's just one object to save/load.

*and* you can always put several objects into a list and
saveRDS() / readRDS() that.

Note: Our pkg {sfsmisc} nowadays contains a nice utility function
list_()  ==> help page online e.g. here
 
https://search.r-project.org/CRAN/refmans/sfsmisc/html/list_named.html

which comes were handy when you want to easily create a *named*
list from a bunch of objects, as e.g. above to be able to nicely use

  saveRDS(list_(obj1, obj2, table3, grob4, data5),
  file = "allthings.rds")
   
The cute utility is very simply defined as

##' list_(a, b, cc)  creates a *named* list  using the actual arguments' names
list_ <- function(...) `names<-`(list(...), vapply(sys.call()[-1L], 
as.character, ""))


> On September 25, 2023 6:23:01 PM PDT, AbouEl-Makarim Aboueissa 
 wrote:
>> Dear ALL:
>> 
>> I am teaching statistical packages class this semester, in R programing I
>> am trying to explain the use of save() and load() with an example using 
the
>> iris data. It seems that the save() function works, BUT when I tried to
>> load the data back to R, it seems that there is a problem(s), I could not
>> figure out what went wrong.
>> 
>> Any help would be highly appreciated.
>> 
>> 
>> I saved the iris data in my computer in the text format, 
"iris.with.head.txt
>> ".
>> 
>> Here are my R codes:
>> 
>>> irisdata<-read.table("G:/iris.with.head.txt", header=T)
>>> 
>>> head(irisdata)
>> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
>> 1  5.1 3.5  1.4 0.2  setosa
>> 2  4.9 3.0  1.4 0.2  setosa
>> 3  4.7 3.2  1.3 0.2  setosa
>> 4  4.6 3.1  1.5 0.2  setosa
>> 5  5.0 3.6  1.4 0.2  setosa
>> 6  5.4 3.9  1.7 0.4  setosa
>> 
>> 
>> 
>> *# saving the data as an .rda*
>> 
>> save(irisdata,file="G:/irisdataTest.rda")
>> 
>> *# load the data back to R*
>> 
>> load(file="G:/irisdataTest.rda")
>> 
>> 
>>> head(irisdataTest)
>> Error in head(irisdataTest) : object 'irisdataTest' not found
>> 
>>> irisdataTest
>> Error: object 'irisdataTest' not found
>> 
>> 
>> 
>> with many thanks
>> abou
>> __
>> 
>> 
>> *AbouEl-Makarim Aboueissa, PhD*
>> 
>> *Professor, Mathematics and Statistics*
>> *Graduate Coordinator*
>> 
>> *Department of Mathematics and Statistics*
>> *University of Southern Maine*
>> 
>> [[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.

> -- 
> Sent from my phone. Please excuse my brevity.

> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To 

[R] car::deltaMethod() fails when a particular combination of categorical variables is not present

2023-09-26 Thread Michael Cohn
I'm running a linear regression with two categorical predictors and their
interaction. One combination of levels does not occur in the data, and as
expected, no parameter is estimated for it. I now want to significance test
a particular combination of levels that does occur in the data (ie, I want
to get a confidence interval for the total prediction at given levels of
each variable).

In the past I've done this using car::deltaMethod() but in this dataset
that does not work, as shown in the example below: The regression model
gives the expected output, but deltaMethod() gives this error:

error in t(gd) %*% vcov. : non-conformable arguments

I believe this is because there is no parameter estimate for when the
predictors have the values 't1' and 'other'. In the df_fixed dataframe,
putting one person into that combination of categories causes deltaMethod()
to work as expected.

I don't know of any theoretical reason that missing one interaction
parameter estimate should prevent getting a confidence interval for a
different combination of predictors. Is there a way to use deltaMethod() or
some other function to do this without changing my data?

Thank you,

- Michael Cohn
Vote Rev (http://voterev.org)


Demonstration:
--

library(car)
# create dataset with outcome and two categorical predictors
outcomes <- c(91,2,60,53,38,78,48,33,97,41,64,84,64,8,66,41,52,18,57,34)
persontype <-
c("t2","t2","t2","t2","t2","t2","t2","t1","t2","t2","t2","t2","t1","t1","t2","t2","t1","t2","t2","t2")
arm_letter <-
c("unsent","unsent","unsent","unsent","sent","unsent","unsent","sent","unsent","unsent","other","unsent","unsent","sent","unsent","other","unsent","sent","sent","unsent")
df <- data.frame(a = outcomes, b=persontype, c=arm_letter)

# note: there are no records with the combination 't1' + 'other'
table(df$b,df$c)


#regression works as expected
minimal_formula <- formula("a ~ b*c")
minimal_model <- lm(minimal_formula, data=df)
summary(minimal_model)

#use deltaMethod() to get a prediction for individuals with the combination
'b2' and 'sent'
# deltaMethod() fails with "error in t(gd) %*% vcov. : non-conformable
arguments."
deltaMethod(minimal_model, "bt2 + csent + `bt2:csent`", rhs=0)

# duplicate the dataset and change one record to be in the previously empty
cell
df_fixed <- df
df_fixed[c(13),"c"] <- 'other'
table(df_fixed$b,df_fixed$c)

#deltaMethod() now works
minimal_model_fixed <- lm(minimal_formula, data=df_fixed)
deltaMethod(minimal_model_fixed, "bt2 + csent + `bt2:csent`", rhs=0)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.