Re: [R] NA rows appeared in data.frame

2019-01-15 Thread PIKAL Petr
Hi

You put NA to some variable in 150 rows. So you do not have "mysterious" NA 
rows in your file. If you want to select anything based on column with NA 
values you have to perform your selection using which (as Rui suggested).

It is documented in help page, although it is probably rather less 
comprehensible (maybe some example added to help page could be useful).
-
NAs in indexing

When extracting, a numerical, logical or character NA index picks an unknown 
element and so returns NA in the corresponding element of a logical, integer, 
numeric, complex or character result, and NULL for a list. (It returns 00 for a 
raw result.)
-
I believe that this behaviour has some reason, because you compare 2 to NA and 
NA is basically "I do not know". So it could be 2 and therefore also rows with 
NA are returned. If I am wrong, I hope R gurus will correct me.

You said you want to remove rows with NA values, therefore I suggested 
complete.cases function. After this you end with object stripped from rows with 
NA values so with less rows.

I would be rather cautious with word "errorneous". I remember old days when 
Excel considered empty cells as zeros and gave "errorneous" calculations but I 
believe that it was pretty sensible from accountant point of view as empty cell 
means 0.

In almost all cases, analysis in R give you correct results, you just need to 
tell R how to apply function to object with NA values.
> mean(t1$Petal.Width)
[1] NA
> mean(t1$Petal.Width, na.rm=T)
[1] 1.147101
>

Cheers
Petr


> -Original Message-
> From: Ernest Han 
> Sent: Wednesday, January 16, 2019 3:27 AM
> To: PIKAL Petr 
> Cc: r-help@r-project.org
> Subject: Re: [R] NA rows appeared in data.frame
>
> Dear Rui and Petr,
>
> Thank you for taking time and effort to help.
>
> Rui's solution is an effective workaround so that I can continue to work with
> the data. However, the appearance of these NA rows (with NA
> rownames) is clearly errorneous (possibly a bug behaviour due to R base code).
> What I am interested is a solution that removes these NA rows.
>
> The reasons is because (1) prior to the NA assignment, one does not need to
> test for NA value. (2) Besides, sometimes these NA values are needed as part 
> of
> the data to indicate that the missing data.
>
> > t1[t1$Petal.Width==1.8, "Petal.Width"] <- NA
>
> Petr's solution is also not apt in my case, because it removes 12 rows that 
> have
> NA values in "Petal.Width". I would like a solution that keeps the 150 rows, 
> but
> not the mysterious 12 rows with all NA values in all columns.

Now I am puzzled what do you really want?

with your example and my suggestion you get

t1 <- iris
t1[t1$Petal.Width==1.8, "Petal.Width"] <- NA
t2 <- t1[!is.na(t1$Petal.Width),]
t2[t2$Petal.Width == 2.0, ]
Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
111  6.5 3.2  5.1   2 virginica
114  5.7 2.5  5.0   2 virginica
122  5.6 2.8  4.9   2 virginica
123  7.7 2.8  6.7   2 virginica
132  7.9 3.8  6.4   2 virginica
148  6.5 3.0  5.2   2 virginica
>

> dim(t2)
[1] 138   5
> dim(t1)
[1] 150   5
>

>
> Once again, I appreciate your suggestions and I am hoping that this 
> 'errorneous'
> behaviour has a fix.
>
> Cheers,
> Ernest
>
> On Mon, Jan 14, 2019 at 4:25 PM PIKAL Petr  wrote:
> >
> > Hi
> >
> > If you want to remove rows with NA values from your data you could use
> >
> > ?complete.cases
> >
> > or
> >
> > t2 <- t1[!is.na(t1$Petal.Width),]
> >
> > Cheers
> > Petr
> >
> > > -Original Message-
> > > From: R-help  On Behalf Of Rui
> > > Barradas
> > > Sent: Saturday, January 12, 2019 12:55 PM
> > > To: Ernest Han ; r-help@r-project.org
> > > Subject: Re: [R] NA rows appeared in data.frame
> > >
> > > Hello,
> > >
> > > You have to test for NA. Some (12) of the values of t1$Petal.Width
> > > are NA therefore t1$Petal.Width == 2.0 alone returns 12 NA values.
> > >
> > > t1[t1$Petal.Width == 2.0 & !is.na(t1$Petal.Width == 2.0), ]
> > >
> > > Or use which(t1$Petal.Width == 2.0).
> > >
> > > t1[which(t1$Petal.Width == 2.0), ]
> > >
> > >
> > > Hope this helps,
> > >
> > > Rui Barradas
> > >
> > > Às 08:23 de 12/01/2019, Ernest Han escreveu:
> > > > Dear All,
> > > >
> > > > After replacing some values in a data.frame, NAs rows have
> > > > appeared and cannot be removed. I have googled these issues and
> > > > found that several people have encountered it. Solutions in
> > > > stackoverflow seem to provide work-arounds but does not remove it from
> the data.frame.
> > > > Therefore, I am turning to experts in this community for help.
> > > >
> > > > The code is as follows,
> > > >
> > > >> t1 <- iris
> > > >> t1[t1$Petal.Width==1.8, "Petal.Width"] <- NA t1[t1$Petal.Width ==
> > > >> 2.0, ]
> > > >Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
> > > 

[R-es] optimizacion costos

2019-01-15 Thread Javier Marcuzzi
Estimados.

Hace un tiempo que tengo una duda, estaba pensando en los problemas como
optimización de costos, donde hay varias alternativas y librerías, pasando
por soluciones inspiradas en energía, genética o algo matemático como
matrices y álgebra.

Luego aparecen tensorflow, cntk, y otros tantos, de los cuáles
https://keras.rstudio.com/ ofrece alternativas para mezclar los mundos por
decirlo de alguna forma.

De estos si miro https://keras.rstudio.com/ observo en la documentación lo
que aparece siempre, la optimización. En este caso sería lo siguiente:

model %>% compile
(
  loss = 'categorical_crossentropy',
  optimizer = optimizer_rmsprop
(),
  metrics = c('accuracy')
)

Ahora mi pregunta, es posible con esos optimizadores, tomar un problema
para producir a mínimo costo, o al contrario, para maximizar las ganancias?

Alguno de ustedes vio un ejemplo al respecto? No me refiero a los muchos
desarrollados en el R clásico, sino en R que conecta por ejemplo a
tensorflow con keras, o en su defecto python que conecta muy simple con
tensorflow.

Con R lo resuelvo, pero me crea la duda estos optimizadores y no he
explorado esa alternativa pero me intriga y lo intentaría de puro gusto o
desafío personal.

Agradezco comentarios.

Javier Rubén Marcuzzi

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Error with install.packages using R v 3.5.1 and 3.5.2

2019-01-15 Thread Jeff Newmiller
Please ask questions about Bioconductor on the Bioconductor forum [1].

Chances are that you need to re-install Bioconductor because packages are 
installed in two-digit version-specific libraries... e.g. R 3.4 and R 3.5 do 
not share packages.

[1] https://support.bioconductor.org

On January 15, 2019 11:51:16 AM PST, Emily Wan  
wrote:
>Hi -
>I am working with R on a Window Server 2012 R2 - I had originally
>installed
>R (v3.5.1) in September/October 2018 and have used multiple packages
>without incident. However, last week, when attempting to install
>additional
>packages (using install.packages() or Bioconductor's
>BiocManager::install()
>wrapper), I kept on receiving the following error message:
>
>Error in if (any(diff)) { : missing value where TRUE/FALSE needed
>
>I have searched the prior threads on this topic (including the issue
>reported with R v3.4.0 which required a patch), rebooted my server, and
>actually uninstalled R v3.5.1 and upgraded to v3.5.2 but am still
>receiving
>the same error message when I attempt to install *any* package.
>Please let me know what additional details I can provide to assist with
>troubleshooting. Thank you.

-- 
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] Rserve - Request assistance with installation, confirmation thereof and starting (R 3.5.1 on 64-bit Win7 Pro)

2019-01-15 Thread Rick Van Camp
Hello,

I am attempting to install two R packages with specific version numbers.
These are Rserve_1.8-0.zip and MASS_7.3-45.zip.  As the file extension
suggests, I am installing packages from local zipfiles in the GUI Packages
menu.  R Console displays positive feedback when MASS is loaded in this
manner:

*> utils:::menuInstallLocal()*

package ‘MASS’ successfully unpacked and MD5 sums checked

The R Console does not display any message when I attempt to install Rserve
in the same manner.  What does this indicate about Rserve being installed
successfully?  I was only provided instructions to install these two
packages. No mention is made af loading them and this is feasible as Rserve
can run without R being open.

Further, I recently located two discussion threads indicating Rserve
requires a configuration file and this is created by the user.  These
threads refer the reader to three files: 1) Rserve.exe, 2) Rserve.dll, and
3) Rserve_d.exe and instructs these should be placed into the same
directory where R.dll is located (This is the bin directory on my
installation: R.home("bin")).  Next, it instructs readers to create the
file "Rserv.cfg" and provide the desired arguments such port number.

Here is my result of sessionInfo()

*> sessionInfo()*

R version 3.5.1 (2018-07-02)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows 7 x64 (build 7601) Service Pack 1


Matrix products: default


locale:

[1] LC_COLLATE=English_United States.1252

[2] LC_CTYPE=English_United States.1252

[3] LC_MONETARY=English_United States.1252

[4] LC_NUMERIC=C

[5] LC_TIME=English_United States.1252


attached base packages:

[1] stats graphics grDevices utils datasets methods base


loaded via a namespace (and not attached):

[1] compiler_3.5.1 tools_3.5.1


Please let me know if you need anything else regarding my installation of
R.  Since I have been unable to accomplish this task, I have not saved a
workspace.


Thank you.

[[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] Error with install.packages using R v 3.5.1 and 3.5.2

2019-01-15 Thread Emily Wan
Hi -
I am working with R on a Window Server 2012 R2 - I had originally installed
R (v3.5.1) in September/October 2018 and have used multiple packages
without incident. However, last week, when attempting to install additional
packages (using install.packages() or Bioconductor's BiocManager::install()
wrapper), I kept on receiving the following error message:

Error in if (any(diff)) { : missing value where TRUE/FALSE needed

I have searched the prior threads on this topic (including the issue
reported with R v3.4.0 which required a patch), rebooted my server, and
actually uninstalled R v3.5.1 and upgraded to v3.5.2 but am still receiving
the same error message when I attempt to install *any* package.
Please let me know what additional details I can provide to assist with
troubleshooting. Thank you.

-- 
The information in this e-mail is intended only for the ...{{dropped:18}}

__
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] Banner using R

2019-01-15 Thread David L Carlson
You need to read the data without converting to factors:

> Data <- data.frame(v1 = c('A', 'B' ,'B' ,'A', 'B'), v2 =c('A', 'B', 'A', 'A', 
> 'B'), 
+  v3 = c('A', 'A', 'A', 'A', 'A'), stringsAsFactors=FALSE)

Then you need to stack it:

> Data.stack <- stack(Data)
> str(Data.stack)
'data.frame':   15 obs. of  2 variables:
 $ values: chr  "A" "B" "B" "A" ...
 $ ind   : Factor w/ 3 levels "v1","v2","v3": 1 1 1 1 1 2 2 2 2 2 ...

Then table (or xtabs) will work:

> Data.tbl <- table(Data.stack)
> addmargins(Data.tbl, 2)
  ind
values v1 v2 v3 Sum
 A  2  3  5  10
 B  3  2  0   5


David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77843-4352

-Original Message-
From: R-help  On Behalf Of Luca Meyer
Sent: Tuesday, January 15, 2019 12:26 PM
To: r-help@r-project.org
Subject: [R] Banner using R

Hi,

I am a bit rusty with R programming and I would appreciate some assistance with 
the following.

I have a dataset like:

Data <- data.frame(v1 = c('A', 'B' ,'B' ,'A', 'B'), v2 =c('A', 'B', 'A', 'A', 
'B'), v3 = c('A', 'A', 'A', 'A', 'A’))

How can I get a banner of the sort?

Count   v1  v2  v3  TOT
A   2   3   5   10
B   3   2   0   5

I have tried with xtabs and expss but I do not seem to get what I need...

Thanks,

Luca

__
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.


[R] Nested mixed effectts question

2019-01-15 Thread Caroline
Hi,

I am helping a friend with an analysis for a study where she sampled wrack 
biomass in 15 different sites across three years. At each site, she sampled 
from three different transects. She is trying to estimate the effect of 
year*site on biomass while accounting for the nested nature (site/transcet) and 
repeated measure study design. 

wrack.biomass ~ year * site + (1 | site/trans)

However she gets the following warning messages:
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
   Hessian is numerically singular: parameters are not uniquely determined

And her model output is: 

> summary(wrackbio)
Linear mixed model fit by REML 
t-tests use  Satterthwaite approximations to degrees of freedom ['lmerMod']
Formula: (actual.mean.biomass.m2.50.m.transect) ~ year * site + (1 | site/trans)
   Data: wrack_resp_allyrs_transname

REML criterion at convergence: 691

Scaled residuals: 
Min  1Q  Median  3Q Max 
-3.3292 -0.2624 -0.0270  0.1681  3.8024 

Random effects:
 Groups NameVariance Std.Dev.
 trans:site (Intercept)  0.  0.  
 site   (Intercept)  0.5531  0.7437  
 Residual   94.6453  9.7286  
Number of obs: 132, groups:  trans:site, 44; site, 15

Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept)9.692e+00  5.666e+00  1.119e-04   1.7110.999
year2016   1.256e+01  7.943e+00  8.700e+01   1.5820.117
year2017   2.395e+00  7.943e+00  8.700e+01   0.3020.764
siteCL 5.672e+01  8.013e+00  1.119e-04   7.0790.999
siteDO-4.315e+00  8.013e+00  1.119e-04  -0.5390.999
siteFL 7.872e+00  8.013e+00  1.119e-04   0.9820.999
siteFS-7.619e+00  8.013e+00  1.119e-04  -0.9510.999
siteGH 4.369e+00  8.013e+00  1.119e-04   0.5450.999
siteLB-3.747e+00  8.013e+00  1.119e-04  -0.4680.999
siteLBP   -5.298e+00  8.943e+00  1.736e-04  -0.5920.999
siteNB-2.953e+00  8.013e+00  1.119e-04  -0.3691.000
siteNS 1.005e+00  8.013e+00  1.119e-04   0.1251.000
sitePC-5.238e+00  8.013e+00  1.119e-04  -0.6540.999
siteSB-7.649e+00  8.013e+00  1.119e-04  -0.9550.999
siteSILT  -4.734e+00  8.013e+00  1.119e-04  -0.5910.999
siteSL-7.890e+00  8.013e+00  1.119e-04  -0.9850.999
siteUD-8.230e+00  8.013e+00  1.119e-04  -1.0270.999
year2016:siteCL   -6.359e+01  1.123e+01  8.700e+01  -5.660 1.91e-07 ***
year2017:siteCL   -5.210e+01  1.123e+01  8.700e+01  -4.638 1.23e-05 ***
year2016:siteDO   -1.550e+01  1.123e+01  8.700e+01  -1.3800.171
year2017:siteDO   -3.022e+00  1.123e+01  8.700e+01  -0.2690.789
year2016:siteFL   -7.522e+00  1.123e+01  8.700e+01  -0.6700.505
year2017:siteFL   -1.167e+01  1.123e+01  8.700e+01  -1.0390.302
year2016:siteFS   -1.391e+01  1.123e+01  8.700e+01  -1.2380.219
year2017:siteFS   -2.170e+00  1.123e+01  8.700e+01  -0.1930.847
year2016:siteGH   -9.135e+00  1.123e+01  8.700e+01  -0.8130.418
year2017:siteGH   -4.031e+00  1.123e+01  8.700e+01  -0.3590.721
year2016:siteLB   -8.668e+00  1.123e+01  8.700e+01  -0.7720.442
year2017:siteLB   -1.530e+00  1.123e+01  8.700e+01  -0.1360.892
year2016:siteLBP  -5.336e+00  1.256e+01  8.700e+01  -0.4250.672
year2017:siteLBP  -1.826e+00  1.256e+01  8.700e+01  -0.1450.885
year2016:siteNB   -7.999e+00  1.123e+01  8.700e+01  -0.7120.478
year2017:siteNB   -5.645e+00  1.123e+01  8.700e+01  -0.5020.617
year2016:siteNS   -8.871e+00  1.123e+01  8.700e+01  -0.7900.432
year2017:siteNS   -3.443e+00  1.123e+01  8.700e+01  -0.3060.760
year2016:sitePC   -1.603e+01  1.123e+01  8.700e+01  -1.4270.157
year2017:sitePC   -2.955e+00  1.123e+01  8.700e+01  -0.2630.793
year2016:siteSB   -1.316e+01  1.123e+01  8.700e+01  -1.1710.245
year2017:siteSB   -3.220e+00  1.123e+01  8.700e+01  -0.2870.775
year2016:siteSILT -1.616e+01  1.123e+01  8.700e+01  -1.4380.154
year2017:siteSILT -2.497e-01  1.123e+01  8.700e+01  -0.0220.982
year2016:siteSL   -1.004e+01  1.123e+01  8.700e+01  -0.8940.374
year2017:siteSL1.123e+00  1.123e+01  8.700e+01   0.1000.921
year2016:siteUD   -1.345e+01  1.123e+01  8.700e+01  -1.1970.235
year2017:siteUD3.810e+00  1.123e+01  8.700e+01   0.3390.735
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation matrix not shown by default, as p = 45 > 12.
Use print(x, correlation=TRUE)  or
vcov(x)if you need it

convergence code: 0
unable to evaluate scaled gradient
 Hessian is numerically singular: parameters 

Re: [R] [R-sig-ME] Calculating F values for lme function

2019-01-15 Thread peter dalgaard
Or at least don't do it with lme() because it basically gets them wrong (I 
believe even its author agrees). The situation is rather better with lme4 and 
the pbkrtest package, although one should always be wary of low denominator DF 
cases because, even at the best of times, results rely heavily on assumptions 
of normal distribution.

-pd

> On 15 Jan 2019, at 18:42 , Bert Gunter  wrote:
> 
> Ricardo:
> You may do better posting on the r-sig-mixed-models list, which is
> specifically devoted to such topics.
> 
> FWIW, re calculating F-values for mixed effects models, I think many say:
> don't.
> 
> Bert Gunter
> 
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> 
> 
> On Tue, Jan 15, 2019 at 8:36 AM Jeff Newmiller 
> wrote:
> 
>> You should use Reply-All to make sure the discussion continues to include
>> the mailing list.
>> 
>> Have you looked at the help for lme?
>> 
>> lme is non-trivial, so it may take some reading. I only have a few of the
>> references listed in the help file, and none with me at the moment.
>> 
>> On January 15, 2019 7:36:22 AM PST, RICARDO ALVARADO BARRANTES <
>> ricardo.alvar...@ucr.ac.cr> wrote:
>>> Thanks for your response, however my understandig of all this
>>> programming is very limited. Is there any source where I can read about
>>> F calculation for those models?
>>> 
>>> Thanks for your time
>>> 
>>> Ricardo
>>> 
>>> El 14-01-2019 16:47, Jeff Newmiller escribió:
>>> 
 Fortunately, nlme is open source [1 [1]][2 [2]], so you can follow
>>> along in as much detail as you like.
 
 Note that capitalization matters in R... NLME is not correct.
 
 [1]  https://github.com/cran/nlme/blob/master/R/lme.R
 [2] https://cran.r-project.org/package=nlme
 
 On January 14, 2019 1:59:29 PM PST, RICARDO ALVARADO BARRANTES
>>>  wrote:
 
> I have a question related to the funcion LME in the library NLME.  I
> would like to understand how the F values are calculated, since the
> output only shows the degrees of freedom but doen't show the sums of
> squares involved in those calculations.
> 
> Thanks for your attention.
> 
> Ricardo
> 
> [[alternative HTML version deleted]]
> 
> ___
> r-sig-mixed-mod...@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>> 
>>> 
>>> 
>>> Links:
>>> --
>>> [1] https://github.com/cran/nlme/blob/master/R/lme.R
>>> [2] https://cran.r-project.org/package=nlme
>> 
>> --
>> 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.
>> 
> 
>   [[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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
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] Banner using R

2019-01-15 Thread Luca Meyer
Hi,

I am a bit rusty with R programming and I would appreciate some assistance with 
the following.

I have a dataset like:

Data <- data.frame(v1 = c('A', 'B' ,'B' ,'A', 'B'), v2 =c('A', 'B', 'A', 'A', 
'B'), v3 = c('A', 'A', 'A', 'A', 'A’))

How can I get a banner of the sort?

Count   v1  v2  v3  TOT
A   2   3   5   10
B   3   2   0   5

I have tried with xtabs and expss but I do not seem to get what I need...

Thanks,

Luca

__
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] [R-sig-ME] Calculating F values for lme function

2019-01-15 Thread Bert Gunter
Ricardo:
You may do better posting on the r-sig-mixed-models list, which is
specifically devoted to such topics.

FWIW, re calculating F-values for mixed effects models, I think many say:
don't.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Jan 15, 2019 at 8:36 AM Jeff Newmiller 
wrote:

> You should use Reply-All to make sure the discussion continues to include
> the mailing list.
>
> Have you looked at the help for lme?
>
> lme is non-trivial, so it may take some reading. I only have a few of the
> references listed in the help file, and none with me at the moment.
>
> On January 15, 2019 7:36:22 AM PST, RICARDO ALVARADO BARRANTES <
> ricardo.alvar...@ucr.ac.cr> wrote:
> >Thanks for your response, however my understandig of all this
> >programming is very limited. Is there any source where I can read about
> >F calculation for those models?
> >
> >Thanks for your time
> >
> >Ricardo
> >
> >El 14-01-2019 16:47, Jeff Newmiller escribió:
> >
> >> Fortunately, nlme is open source [1 [1]][2 [2]], so you can follow
> >along in as much detail as you like.
> >>
> >> Note that capitalization matters in R... NLME is not correct.
> >>
> >> [1]  https://github.com/cran/nlme/blob/master/R/lme.R
> >> [2] https://cran.r-project.org/package=nlme
> >>
> >> On January 14, 2019 1:59:29 PM PST, RICARDO ALVARADO BARRANTES
> > wrote:
> >>
> >>> I have a question related to the funcion LME in the library NLME.  I
> >>> would like to understand how the F values are calculated, since the
> >>> output only shows the degrees of freedom but doen't show the sums of
> >>> squares involved in those calculations.
> >>>
> >>> Thanks for your attention.
> >>>
> >>> Ricardo
> >>>
> >>> [[alternative HTML version deleted]]
> >>>
> >>> ___
> >>> r-sig-mixed-mod...@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> >
> >
> >
> >Links:
> >--
> >[1] https://github.com/cran/nlme/blob/master/R/lme.R
> >[2] https://cran.r-project.org/package=nlme
>
> --
> 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.
>

[[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] [R-sig-ME] Calculating F values for lme function

2019-01-15 Thread Jeff Newmiller
You should use Reply-All to make sure the discussion continues to include the 
mailing list.

Have you looked at the help for lme?

lme is non-trivial, so it may take some reading. I only have a few of the 
references listed in the help file, and none with me at the moment.

On January 15, 2019 7:36:22 AM PST, RICARDO ALVARADO BARRANTES 
 wrote:
>Thanks for your response, however my understandig of all this
>programming is very limited. Is there any source where I can read about
>F calculation for those models? 
>
>Thanks for your time 
>
>Ricardo 
>
>El 14-01-2019 16:47, Jeff Newmiller escribió:
>
>> Fortunately, nlme is open source [1 [1]][2 [2]], so you can follow
>along in as much detail as you like.
>> 
>> Note that capitalization matters in R... NLME is not correct.
>> 
>> [1]  https://github.com/cran/nlme/blob/master/R/lme.R
>> [2] https://cran.r-project.org/package=nlme
>> 
>> On January 14, 2019 1:59:29 PM PST, RICARDO ALVARADO BARRANTES
> wrote: 
>> 
>>> I have a question related to the funcion LME in the library NLME.  I
>>> would like to understand how the F values are calculated, since the
>>> output only shows the degrees of freedom but doen't show the sums of
>>> squares involved in those calculations. 
>>> 
>>> Thanks for your attention. 
>>> 
>>> Ricardo
>>> 
>>> [[alternative HTML version deleted]]
>>> 
>>> ___
>>> r-sig-mixed-mod...@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>  
>
>Links:
>--
>[1] https://github.com/cran/nlme/blob/master/R/lme.R
>[2] https://cran.r-project.org/package=nlme

-- 
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.


Re: [R] CRAN package NlcOptim query

2019-01-15 Thread Hans W Borchers
To be corrected:
`Constr_new` with a capital letter;
`aeq2` is a list, should be a matrix.

As I said last month, you can yourself combine inequality constraints
with bounds constraints as follows:

myA <- rbind(-Constr_new, diag(-1,numel), diag(1,numel))
myB <- c(-x_than0, rep(0,numel), rep(1,numel))

and `solnl` will return a result like this:

sol <- NlcOptim::solnl(X = c(InputTM), objfun = obj_F, A = myA, B = myB,
   Aeq = as.matrix(aeq2), Beq = beq2)
c(sol$par)
[1] 0.8310997170, 0.0378150241, ..., 0.2463006547, 1.00
sol$fn
[1] 0.00421616

I will write to the maintainer asking about why this example does not
work --  supplying functioning code, maybe that will trigger a
response.

Hans Werner

Please note: You are sending e-mail in HTML format which makes it
almost impossible to use as code in the R console.

On Wed, Dec 12, 2018 at 12:45 PM Hans W Borchers  wrote:
>
> This is still not complete: `x_than0` is missing.
> `Constr_new` is written with a capital 'C'.
> And aeq2 is a list of column vectors, not a matrix.
> Setting the tolerance to 0 does not seem to be a good idea.
>
> Making aeq2 a matrix and adding `x_than0 <- matrix(c(1, 1))`, then
>
> aeq2 <- as.matrix(aeq2)
> x_than0 <- matrix(c(1, 1))
>
> NlcOptim::solnl(X=c(InputTM), objfun=obj_F, A=-Constr_new, B=-x_than0,
> Aeq=as.matrix(aeq2), Beq=beq2,
> lb=c(rep(0,numel)),ub=c(rep(1,numel)), tolX = 0)
>
> will indeed return in the same error, while it runs without error if you
> either leave out the inequality constraints or the bounds constraints. So
> I guess there may be a bug when the function internally combines these
> constraints and the bounds.
>
> You could / should write to the maintainer. I know he is very responsive.
>
> For the moment, you can combine the bounds constraints and the lower and
> upper bounds yourself:
>
> myA <- rbind(-Constr_new, diag(-1,numel), diag(1,numel))
> myB <- c(-x_than0, rep(0,numel), rep(1,numel))
>
> NlcOptim::solnl(X=c(InputTM), objfun=obj_F, A=myA, B=myB,
> Aeq=as.matrix(aeq2), Beq=beq2)
>
> returns "constraints are inconsistent, no solution!", but that may be the
> case because I don't know your `x_than` value.

__
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] do.call, browser and traceback

2019-01-15 Thread Sigbert Klinke

Hi,

I run in the same problem, as discussed in 2006. Is there any solution 
by now?


Sigbert

Am 23.02.06 um 20:39 schrieb hadley wickham:

Did you mean that?  Both are errors.  Perhaps

f <- function(...) browser()
do.call(f, mtcars)


Sorry, yes, that is what I meant.


What is being used is

 Rprintf("Called from: ");
 PrintValueRec(cptr->call,rho);

in src/main/main.c.  We could certainly allow an option to limit the
deparse length, but I have to say that quite often the useful information
is well down the list of arguments.  There is currently no user control.


It would be nice to have some user control - I find the first 100
characters or so is usually sufficient, especially when the real
problem is further down the stack.  It is a real pain when you have
used do.call with a 10,000 row dataframe - and then it is basically
impossible to find the problem by manual inspection anyway.  Even
limiting to 1000 characters would be a big improvement.

Hadley

__
r-h...@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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.