Re: [R] R coding errors

2023-09-08 Thread John Kane
Can you supply us with some sample data?

 A handy way to supply some sample data is the dput() function.  In the
case of a large dataset something like dput(head(mydata, 100)) should
supply the data we need. Just do dput(mydata) where *mydata* is your data.
Copy the output and paste it here.

On Fri, 8 Sept 2023 at 10:42, PROFESOR MADYA DR NORHAYATI BAHARUN <
norha...@uitm.edu.my> wrote:

> Hi Sir,
>
> Could you please help me on the following errors:
>
> STEPS TO MIX IRT_RMT APPROACH IN R
>
> #1- Load required libraries
> library(eRm)
> library(ltm)
> library(mirt)
> library(psych)
>
> HT <- read.csv("C:/Users/User/Dropbox/Analysis R_2023/HT2.csv")
> str(HT)
>
> #2- Load or create your data matrix
> response_columns <- HT[, 1:ncol(HT)]
> response_matrix <- as.matrix(response_columns)
>
> #3- Fit IRT model
> irt_model <- gpcm(response_matrix)
> irt_model
> summary(irt_model)
>
> #4- Fit Rasch model
> rasch_model <- PCM(response_matrix)
> rasch_model
> summary(rasch_model)
>
> #5- Compare item parameter estimates between IRT and Rasch models
> irt_item_parameters <- coef(irt_model)
> rasch_item_parameters <- coef(rasch_model)
>
> #6- Compare person ability estimates between IRT and Rasch models
> #TRY1
> irt_person_abilities <- fscores(irt_model)###ERROR###
> #TRY2
> #a(IRT)- Fit your GPCM model using ltm
> irt_model <- gpcm(data = HT, constraint = "1PL")
>
> #a(IRT)- Calculate factor scores (IRT person abilities)
> irt_person_abilities <- factor.scores(irt_model) ###ERROR###
> irt_person_abilities_dim1 <- factor.scores(gpcm_model, f = 1)
>
> #TRY3
> # Fit your GPCM model using mirt
> irt_model <- mirt(data = HT, model = "gpcm", itemtype = "graded")
>  ###ERROR###
>
> # Calculate factor scores for dimension 1 (adjust the dimension as needed)
> irt_person_abilities_dim1 <- fscores(gpcm_model, method = "EAP", dims = 1)
>
>
> #b(RMT)
> rasch_person_abilities <- person.parameter(rasch_model)$theta
>
>
> #7- Perform model comparison using fit statistics (e.g., AIC, BIC)
> irt_aic <- AIC(irt_model)
> rasch_aic <- AIC(rasch_model)
>
> irt_bic <- BIC(irt_model)
> rasch_bic <- BIC(rasch_model)
>
> #8- Print or visualize the results for comparison
> print("Item Parameter Estimates:")
> print(irt_item_parameters)
> print(rasch_item_parameters)
>
> print("Person Ability Estimates:")
> print(irt_person_abilities)  ###ERROR###
> print(rasch_person_abilities)
>
> print("Model Fit Statistics:")
> print(paste("IRT AIC:", irt_aic))
> print(paste("Rasch AIC:", rasch_aic))
>
> print(paste("IRT BIC:", irt_bic))
> print(paste("Rasch BIC:", rasch_bic))
>
> Hope to get your response.
>
> Many thanks.
>
> Regards,
>
> Norhayati
>
> --
>
>
>
>
> *PENAFIAN: *E-mel ini dan apa-apa fail yang dihantar
> bersama-samanya
> ("Mesej") adalah dihasratkan hanya untuk kegunaan
> penerima yang dinyatakan
> di atas dan mungkin mengandungi maklumat yang tidak
> umum, bermilik,
> istimewa, sulit dan dikecualikan dari penzahiran di bawah
> undang-undang
> yang terpakai termasuklah Akta Rahsia Rasmi 1972. *BACA SELANJUTNYA...*
> *DISCLAIMER
>
> :** This e-mail and any files transmitted with it
> ("Message") is intended
> only for the use of the recipient(s) named
> above and may contain
> information that is non-public,  proprietary,
> privileged,  confidential
> and
> exempt  from  disclosure under applicable law including the
> Official
> Secrets Act 1972. **READ MORE...*
> 
>
> [[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.
>


-- 
John Kane
Kingston ON Canada

[[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] unable to load latticeExtra in AWS R

2023-09-08 Thread Ivan Krylov
8 сентября 2023 г. 22:25:10 UTC, Naresh Gurbuxani 
 пишет:
>> library(latticeExtra)
> Error: package or namespace load failed for ‘latticeExtra’ in dyn.load(file, 
> DLLpath = DLLpath, ...):
>  unable to load shared object 
> '/home/ec2-user/SageMaker/R-library/jpeg/libs/jpeg.so':
>   libjpeg.so.8: cannot open shared object file: No such file or directory

>!> sessionInfo()
> R version 4.2.3 (2023-03-15)
> Platform: x86_64-conda-linux-gnu (64-bit)
> Running under: Amazon Linux 2
Sounds like an LD_LIBRARY_PATH problem. How did you install the jpeg package? 
Try reinstalling it.
-- 
Best regards,
Ivan

__
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] unable to load latticeExtra in AWS R

2023-09-08 Thread Naresh Gurbuxani
In my AWS Sagemaker account latticeExtra does not load.  It has worked in the 
past.

How can this problem be fixed?

Thanks,
Naresh

Sent from my iPhone

Begin forwarded message:

Lattice package is preinstalled.  I installed latticeExtra.
> .libPaths()
 [1] "/home/ec2-user/SageMaker/R-library"
 [2] "/home/ec2-user/anaconda3/envs/R/lib/R/library"
> find.package("lattice")
 [1] "/home/ec2-user/anaconda3/envs/R/lib/R/library/lattice"
> find.package("latticeExtra")
 [1] "/home/ec2-user/SageMaker/R-library/latticeExtra"
> library(latticeExtra)
 Error: package or namespace load failed for ‘latticeExtra’ in dyn.load(file, 
DLLpath = DLLpath, ...):
  unable to load shared object 
'/home/ec2-user/SageMaker/R-library/jpeg/libs/jpeg.so':
   libjpeg.so.8: cannot open shared object file: No such file or directory
 > find.package("jpeg")
 [1] "/home/ec2-user/SageMaker/R-library/jpeg"
 > dir("/home/ec2-user/SageMaker/R-library/jpeg/libs/jpeg.so")
 character(0)
 > file.exists("/home/ec2-user/SageMaker/R-library/jpeg/libs/jpeg.so")
 [1] TRUE
!> sessionInfo()
 R version 4.2.3 (2023-03-15)
 Platform: x86_64-conda-linux-gnu (64-bit)
 Running under: Amazon Linux 2

 Matrix products: default
 BLAS/LAPACK: /home/ec2-user/anaconda3/envs/R/lib/libopenblasp-r0.3.23.so

 locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base

 other attached packages:
 [1] lattice_0.21-8

 loaded via a namespace (and not attached):
 [1] compiler_4.2.3 tools_4.2.3RColorBrewer_1.1-3 grid_4.2.3
 [5] png_0.1-8

[[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-es] Problemas usando python a través de reticulate in macos arm64

2023-09-08 Thread Manuel Spínola
Muchas gracias Carlos.

Muy clara tu explicación.

Ahora voy a ver si puedo usar reticulate sin problema.

Manuel

On Fri, 8 Sep 2023 at 11:41 Carlos Ortega  wrote:

> Sí, eso es.
>
>- Puedes tener diferentes entornos de este tipo.
>- Lo normal es tener uno que es el que usas más frecuentemente.
>- Pero en algún momento, te puede interesar instalar una librería
>especial que exige una versión de Python diferente a la que tienes en ese
>otro entorno, entonces te creas un entorno nuevo experimental para esto.
>   - O vaya, si desarrollas algo y no quieres que se rompa tu código
>   si actualizas las librerías, te crearías otro entorno nuevo con las
>   librerías actualizadas para desarrollar nuevo código.
>   - Verás que esto de la compatibilidad entre librerías de Python es
>muy complicado de solucionar a veces.
>
> Gracias
> Carlos.
>
> El vie, 8 sept 2023 a las 19:35, Manuel Spínola ()
> escribió:
>
>> Muchas gracias Carlos,
>>
>> Pero entonces ese environmnet solo lo tengo que crear una única vez?
>>
>> Al hacerlo como me dijiste ahora puede ver la versión de conda y python
>> en la Terminal, cosa que antes no podía.
>>
>> Manuel
>>
>> El vie, 8 sept 2023 a las 11:21, Carlos Ortega ()
>> escribió:
>>
>>> Hola Manuel,
>>>
>>> Más o menos... Es más parecido a lo que hace "renv" en R.
>>> En un entorno de Python tienes un conjunto de librerías e incluso una
>>> versión de Python determinada específicas.
>>>
>>> En R, algunas librerías necesitan de Python y lo que hace reticulate es
>>> crear un entorno de estos donde instala las librerías de Python necesarias.
>>> Y lo que hace "reticulate" es convertir objetos de R a Python para que
>>> estas librerías lo procesen. Por ejemplo en la de "keras".
>>>
>>> Pero si te das cuenta, no es mucho más complicado de lo que haces en
>>> "reticulate" cuando dices "install_miniconda()". En la ayuda que te
>>> comenté, todo esto que hace RStudio por tí, lo tendrás que hacer tú. Pero
>>> vaya a efectos de instalación es correr un fichero .sh (shell) para que
>>> instale Miniconda. En la instalación de Miniconda te preguntará en el
>>> terminal donde poner las librerías, pero simplemente con decir "yes" a
>>> todo, lo instala en directorios por defecto.
>>>
>>> Gracias,
>>> Carlos Ortega
>>> www.qualityexcellence.es
>>>
>>> El vie, 8 sept 2023 a las 18:50, Manuel Spínola ()
>>> escribió:
>>>
 Hola Carlos,

 Muchas gracias por tu ayuda.

 Estoy intentando eso, y aunque tengo mucha experiencia en R no soy tan
 bueno en la parte de programación. De ahí mi primera pregunta, que es un
 ambiente en python?  Sienpre se debe trabajar en un ambiente específico en
 python? esto es parecido a un proyecto de RStudio?

 Manuel

 El vie, 8 sept 2023 a las 9:37, Carlos Ortega (<
 c...@qualityexcellence.es>) escribió:

> Hola Manuel,
>
> ¿ Has probado a seguir lo que te indicaba en la lista de R-Help?.
>
> Gracias,
> Carlos Ortega
> www.qualityexcellence.es
>
> El vie, 8 sept 2023 a las 17:25, Manuel Spínola ()
> escribió:
>
>> Hola,
>>
>> Carlos Ortega me sugirió seguir esta discusión en esta lista.
>>
>> library(reticulate)
>>
>> install_miniconda()
>>
>> Cuando escribo lo siguiente en la terminal:
>>
>> conda --version
>>
>> -bash: conda: command not found
>>
>>
>>
>> Y RStudio me pide actualizar de la siguiente manera:
>>
>>
>>
>> ==> WARNING: A newer version of conda exists. <==
>>   current version: 23.3.1
>>   latest version: 23.7.3
>>
>>
>> Please update conda by running
>>
>> $ conda update -n base -c conda-forge conda
>>
>> Or to minimize the number of packages updated during conda update use
>>
>>  conda install conda=23.7.3
>>
>>
>>
>>
>> Escribí en la terminal:
>>
>>
>>
>> conda update -n base -c conda-forge conda
>>
>> -bash: conda: command not found
>>
>>
>>
>> Cómo puedo resolver esto?
>>
>>
>>
>> --
>> *Manuel Spínola, Ph.D.*
>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>> Universidad Nacional
>> Apartado 1350-3000
>> Heredia
>> COSTA RICA
>> mspin...@una.cr 
>> mspinol...@gmail.com
>> Teléfono: (506) 8706 - 4662
>> Sitio web institucional: ICOMVIS
>> 
>> Sitio web personal: Sitio personal <
>> https://mspinola-sitioweb.netlify.app>
>> Blog sobre Ciencia de Datos: Blog de Ciencia de Datos
>> 
>>
>> [[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-es] Problemas usando python a través de reticulate in macos arm64

2023-09-08 Thread Manuel Spínola
Muchas gracias Carlos,

Pero entonces ese environmnet solo lo tengo que crear una única vez?

Al hacerlo como me dijiste ahora puede ver la versión de conda y python en
la Terminal, cosa que antes no podía.

Manuel

El vie, 8 sept 2023 a las 11:21, Carlos Ortega ()
escribió:

> Hola Manuel,
>
> Más o menos... Es más parecido a lo que hace "renv" en R.
> En un entorno de Python tienes un conjunto de librerías e incluso una
> versión de Python determinada específicas.
>
> En R, algunas librerías necesitan de Python y lo que hace reticulate es
> crear un entorno de estos donde instala las librerías de Python necesarias.
> Y lo que hace "reticulate" es convertir objetos de R a Python para que
> estas librerías lo procesen. Por ejemplo en la de "keras".
>
> Pero si te das cuenta, no es mucho más complicado de lo que haces en
> "reticulate" cuando dices "install_miniconda()". En la ayuda que te
> comenté, todo esto que hace RStudio por tí, lo tendrás que hacer tú. Pero
> vaya a efectos de instalación es correr un fichero .sh (shell) para que
> instale Miniconda. En la instalación de Miniconda te preguntará en el
> terminal donde poner las librerías, pero simplemente con decir "yes" a
> todo, lo instala en directorios por defecto.
>
> Gracias,
> Carlos Ortega
> www.qualityexcellence.es
>
> El vie, 8 sept 2023 a las 18:50, Manuel Spínola ()
> escribió:
>
>> Hola Carlos,
>>
>> Muchas gracias por tu ayuda.
>>
>> Estoy intentando eso, y aunque tengo mucha experiencia en R no soy tan
>> bueno en la parte de programación. De ahí mi primera pregunta, que es un
>> ambiente en python?  Sienpre se debe trabajar en un ambiente específico en
>> python? esto es parecido a un proyecto de RStudio?
>>
>> Manuel
>>
>> El vie, 8 sept 2023 a las 9:37, Carlos Ortega ()
>> escribió:
>>
>>> Hola Manuel,
>>>
>>> ¿ Has probado a seguir lo que te indicaba en la lista de R-Help?.
>>>
>>> Gracias,
>>> Carlos Ortega
>>> www.qualityexcellence.es
>>>
>>> El vie, 8 sept 2023 a las 17:25, Manuel Spínola ()
>>> escribió:
>>>
 Hola,

 Carlos Ortega me sugirió seguir esta discusión en esta lista.

 library(reticulate)

 install_miniconda()

 Cuando escribo lo siguiente en la terminal:

 conda --version

 -bash: conda: command not found



 Y RStudio me pide actualizar de la siguiente manera:



 ==> WARNING: A newer version of conda exists. <==
   current version: 23.3.1
   latest version: 23.7.3


 Please update conda by running

 $ conda update -n base -c conda-forge conda

 Or to minimize the number of packages updated during conda update use

  conda install conda=23.7.3




 Escribí en la terminal:



 conda update -n base -c conda-forge conda

 -bash: conda: command not found



 Cómo puedo resolver esto?



 --
 *Manuel Spínola, Ph.D.*
 Instituto Internacional en Conservación y Manejo de Vida Silvestre
 Universidad Nacional
 Apartado 1350-3000
 Heredia
 COSTA RICA
 mspin...@una.cr 
 mspinol...@gmail.com
 Teléfono: (506) 8706 - 4662
 Sitio web institucional: ICOMVIS
 
 Sitio web personal: Sitio personal <
 https://mspinola-sitioweb.netlify.app>
 Blog sobre Ciencia de Datos: Blog de Ciencia de Datos
 

 [[alternative HTML version deleted]]

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

>>>
>>>
>>> --
>>> Saludos,
>>> Carlos Ortega
>>> www.qualityexcellence.es
>>>
>>
>>
>> --
>> *Manuel Spínola, Ph.D.*
>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>> Universidad Nacional
>> Apartado 1350-3000
>> Heredia
>> COSTA RICA
>> mspin...@una.cr 
>> mspinol...@gmail.com
>> Teléfono: (506) 8706 - 4662
>> Sitio web institucional: ICOMVIS
>> 
>> Sitio web personal: Sitio personal
>> 
>> Blog sobre Ciencia de Datos: Blog de Ciencia de Datos
>> 
>>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>


-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Sitio web institucional: ICOMVIS

Sitio web personal: Sitio personal 
Blog sobre Ciencia de Datos: Blog de Ciencia de Datos


[[alternative HTML version deleted]]

___
R-help-es mailing list

Re: [R-es] Problemas usando python a través de reticulate in macos arm64

2023-09-08 Thread Manuel Spínola
Hola Carlos,

Muchas gracias por tu ayuda.

Estoy intentando eso, y aunque tengo mucha experiencia en R no soy tan
bueno en la parte de programación. De ahí mi primera pregunta, que es un
ambiente en python?  Sienpre se debe trabajar en un ambiente específico en
python? esto es parecido a un proyecto de RStudio?

Manuel

El vie, 8 sept 2023 a las 9:37, Carlos Ortega ()
escribió:

> Hola Manuel,
>
> ¿ Has probado a seguir lo que te indicaba en la lista de R-Help?.
>
> Gracias,
> Carlos Ortega
> www.qualityexcellence.es
>
> El vie, 8 sept 2023 a las 17:25, Manuel Spínola ()
> escribió:
>
>> Hola,
>>
>> Carlos Ortega me sugirió seguir esta discusión en esta lista.
>>
>> library(reticulate)
>>
>> install_miniconda()
>>
>> Cuando escribo lo siguiente en la terminal:
>>
>> conda --version
>>
>> -bash: conda: command not found
>>
>>
>>
>> Y RStudio me pide actualizar de la siguiente manera:
>>
>>
>>
>> ==> WARNING: A newer version of conda exists. <==
>>   current version: 23.3.1
>>   latest version: 23.7.3
>>
>>
>> Please update conda by running
>>
>> $ conda update -n base -c conda-forge conda
>>
>> Or to minimize the number of packages updated during conda update use
>>
>>  conda install conda=23.7.3
>>
>>
>>
>>
>> Escribí en la terminal:
>>
>>
>>
>> conda update -n base -c conda-forge conda
>>
>> -bash: conda: command not found
>>
>>
>>
>> Cómo puedo resolver esto?
>>
>>
>>
>> --
>> *Manuel Spínola, Ph.D.*
>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>> Universidad Nacional
>> Apartado 1350-3000
>> Heredia
>> COSTA RICA
>> mspin...@una.cr 
>> mspinol...@gmail.com
>> Teléfono: (506) 8706 - 4662
>> Sitio web institucional: ICOMVIS
>> 
>> Sitio web personal: Sitio personal > >
>> Blog sobre Ciencia de Datos: Blog de Ciencia de Datos
>> 
>>
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>


-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Sitio web institucional: ICOMVIS

Sitio web personal: Sitio personal 
Blog sobre Ciencia de Datos: Blog de Ciencia de Datos


[[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] how to get paste() to output \% so LaTeX will interpret it as a percent sign rather than a comment symbol

2023-09-08 Thread Hadley Wickham
You're getting confused between the contents of the string and the
printed representation of the string. There's a little bit about this
in R4DS: https://r4ds.hadley.nz/strings#escapes

(or in brief, do writeLines(trailing.7.message))

Hadley

On Fri, Sep 8, 2023 at 7:23 AM Christopher Ryan via R-help
 wrote:
>
> I'm using a .Rnw --> Sweave --> pdflatex workflow on Windows 10, with emacs
> 26.3 and ESS (not sure which version.)
>
> I have this code:
>
> n.tests.7 <- 3 ## for example
> trailing.7.pos.percent <- 12  ## for example
> trailing.7.message <-
> ifelse( n.tests.7 > 0,
> paste("In the past seven days,", n.tests.7, "test results have
> been reported, of which", trailing.7.pos.percent, "\\% were positive"),
> paste("No test results have been reported from these labs in
> the past seven days.") )
>
> Desired outcome in the resulting .tex file is "In the past seven days, 3
> test results have been reported, of which 12\% were positive."
>
> But I get "In the past seven days, 3 test results have been reported, of
> which 12\\% were positive." Which, when compiled in pdflatex,
> unsurprisingly cuts off the sentence at 12
>
> Replacing, in the .Rnw code, the \\% with \% , yields an R error message:
>
> Error: '\%' is an unrecognized escape in character string starting ""\%"
>
> Grateful for any help.
>
> --Chris Ryan
>
> [[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.



-- 
http://hadley.nz

__
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-es] Problemas usando python a través de reticulate in macos arm64

2023-09-08 Thread Manuel Spínola
Hola,

Carlos Ortega me sugirió seguir esta discusión en esta lista.

library(reticulate)

install_miniconda()

Cuando escribo lo siguiente en la terminal:

conda --version

-bash: conda: command not found



Y RStudio me pide actualizar de la siguiente manera:



==> WARNING: A newer version of conda exists. <==
  current version: 23.3.1
  latest version: 23.7.3


Please update conda by running

$ conda update -n base -c conda-forge conda

Or to minimize the number of packages updated during conda update use

 conda install conda=23.7.3




Escribí en la terminal:



conda update -n base -c conda-forge conda

-bash: conda: command not found



Cómo puedo resolver esto?



-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Sitio web institucional: ICOMVIS

Sitio web personal: Sitio personal 
Blog sobre Ciencia de Datos: Blog de Ciencia de Datos


[[alternative HTML version deleted]]

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


[R] R coding errors

2023-09-08 Thread PROFESOR MADYA DR NORHAYATI BAHARUN
Hi Sir,

Could you please help me on the following errors:

STEPS TO MIX IRT_RMT APPROACH IN R

#1- Load required libraries
library(eRm)
library(ltm)
library(mirt)
library(psych)

HT <- read.csv("C:/Users/User/Dropbox/Analysis R_2023/HT2.csv")
str(HT)

#2- Load or create your data matrix
response_columns <- HT[, 1:ncol(HT)]
response_matrix <- as.matrix(response_columns)

#3- Fit IRT model
irt_model <- gpcm(response_matrix)
irt_model
summary(irt_model)

#4- Fit Rasch model
rasch_model <- PCM(response_matrix)
rasch_model
summary(rasch_model)

#5- Compare item parameter estimates between IRT and Rasch models
irt_item_parameters <- coef(irt_model)
rasch_item_parameters <- coef(rasch_model)

#6- Compare person ability estimates between IRT and Rasch models
#TRY1
irt_person_abilities <- fscores(irt_model)###ERROR###
#TRY2
#a(IRT)- Fit your GPCM model using ltm
irt_model <- gpcm(data = HT, constraint = "1PL")

#a(IRT)- Calculate factor scores (IRT person abilities)
irt_person_abilities <- factor.scores(irt_model) ###ERROR###
irt_person_abilities_dim1 <- factor.scores(gpcm_model, f = 1)

#TRY3
# Fit your GPCM model using mirt
irt_model <- mirt(data = HT, model = "gpcm", itemtype = "graded")
 ###ERROR###

# Calculate factor scores for dimension 1 (adjust the dimension as needed)
irt_person_abilities_dim1 <- fscores(gpcm_model, method = "EAP", dims = 1)


#b(RMT)
rasch_person_abilities <- person.parameter(rasch_model)$theta


#7- Perform model comparison using fit statistics (e.g., AIC, BIC)
irt_aic <- AIC(irt_model)
rasch_aic <- AIC(rasch_model)

irt_bic <- BIC(irt_model)
rasch_bic <- BIC(rasch_model)

#8- Print or visualize the results for comparison
print("Item Parameter Estimates:")
print(irt_item_parameters)
print(rasch_item_parameters)

print("Person Ability Estimates:")
print(irt_person_abilities)  ###ERROR###
print(rasch_person_abilities)

print("Model Fit Statistics:")
print(paste("IRT AIC:", irt_aic))
print(paste("Rasch AIC:", rasch_aic))

print(paste("IRT BIC:", irt_bic))
print(paste("Rasch BIC:", rasch_bic))

Hope to get your response.

Many thanks.

Regards,

Norhayati

-- 




*PENAFIAN: *E-mel ini dan apa-apa fail yang dihantar
bersama-samanya 
("Mesej") adalah dihasratkan hanya untuk kegunaan
penerima yang dinyatakan 
di atas dan mungkin mengandungi maklumat yang tidak
umum, bermilik, 
istimewa, sulit dan dikecualikan dari penzahiran di bawah
undang-undang 
yang terpakai termasuklah Akta Rahsia Rasmi 1972. *BACA SELANJUTNYA...* 
*DISCLAIMER
 
:** This e-mail and any files transmitted with it
("Message") is intended 
only for the use of the recipient(s) named
above and may contain 
information that is non-public,  proprietary, 
privileged,  confidential  
and 
exempt  from  disclosure under applicable law including the
Official 
Secrets Act 1972. **READ MORE...* 


[[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-es] Orden en los polígonos de Voronoi

2023-09-08 Thread Isidro Hidalgo Arellano via R-help-es
Hola, Carlos:
Lo he resuelto con:
voronoi_esp <- nucleos_esp |>
  st_union() |>
  st_voronoi() |>
  st_collection_extract()
voronoi_esp <- voronoi_esp[unlist(st_intersects(nucleos_esp, voronoi_esp))]

De todas formas , muchas gracias, como siempre.

Isidro Hidalgo Arellano
Observatorio del Mercado de Trabajo
Junta de Comunidades de Castilla – La Mancha


De: Carlos Ortega 
Enviado el: viernes, 8 de septiembre de 2023 16:14
Para: Isidro Hidalgo Arellano 
CC: r-help-es@r-project.org
Asunto: Re: [R-es] Orden en los polígonos de Voronoi

Hola Isidro,

¿Qué tal?
Se lo he preguntado a chatGPT

Y me dice esto:


La función st_voronoi() del paquete sf en R calcula los polígonos de Voronoi a 
partir de un conjunto de puntos. Sin embargo, el orden de los polígonos 
resultantes no necesariamente coincide con el orden de los puntos de entrada.

Para mantener el orden original de los puntos, puedes hacer lo siguiente:

  1.  Calcula los polígonos de Voronoi.
  2.  Para cada punto de entrada, determina cuál polígono de Voronoi contiene 
ese punto. Este paso garantizará que el polígono de Voronoi correspondiente al 
primer punto sea el primero en la lista, y así sucesivamente.
  3.  Almacena los polígonos de Voronoi en el mismo orden que los puntos de 
entrada.

#---
library(sf)

# Crear algunos puntos (sustituir por tus datos)
pts <- st_as_sf(data.frame(x = c(1,3,5), y = c(1,3,2)), coords = c("x", "y"), 
crs = 4326)

# Calcular polígonos de Voronoi
voronoi <- st_voronoi(pts)

# Convertir Voronoi a sf
voronoi_sf <- st_collection_extract(voronoi, "POLYGON")

# Para cada punto, encontrar el polígono de Voronoi correspondiente
order_voronoi <- integer(nrow(pts))

for (i in 1:nrow(pts)) {
  for (j in 1:length(voronoi_sf)) {
if (st_intersects(pts[i, ], voronoi_sf[j, ], sparse = FALSE)[1, 1]) {
  order_voronoi[i] <- j
  break
}
  }
}

# Ordenar polígonos de Voronoi de acuerdo con el orden de los puntos
ordered_voronoi <- voronoi_sf[order_voronoi]

# Ahora, ordered_voronoi tiene los polígonos en el orden deseado.
#---

A ver si así te funciona...

Gracias,
Carlos Ortega
www.qualityexcellence.es

El vie, 8 sept 2023 a las 14:14, Isidro Hidalgo Arellano via R-help-es 
(mailto:r-help-es@r-project.org>>) escribió:
Buenos días:
La función st_voronoi() del paquete sf desordena los polígonos resultantes. La 
he usado con los puntos de los municipios de España y el polígono de Voronoi nº 
1 no es el correspondiente al primer núcleo de población.
¿Sabéis alguna forma de mantener el orden original, según los puntos usados?
He intentado relacionar los polígonos resultantes con cada punto usado. Esto en 
teoría es posible, ya que el punto es el centroide del polígono, pero no doy 
con la tecla:

library(sf)
library(mapSpain)
library(tidyverse)
clm <- esp_get_prov_siane("Castilla-La Mancha", epsg = 3035)
municipios_esp <- esp_get_munic_siane(year = 2019, epsg = 3035) # AVISO: tarda 
un poco
nucleos_esp <- esp_get_capimun(year = 2022, epsg = 3035)
voronoi_esp <- nucleos_esp |>
  st_union() |>
  st_voronoi()

Como siempre, mil gracias...

Isidro Hidalgo Arellano
Observatorio del Mercado de Trabajo
Junta de Comunidades de Castilla - La Mancha


[[alternative HTML version deleted]]

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


--
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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


[R] how to get paste() to output \% so LaTeX will interpret it as a percent sign rather than a comment symbol

2023-09-08 Thread Christopher Ryan via R-help
I'm using a .Rnw --> Sweave --> pdflatex workflow on Windows 10, with emacs
26.3 and ESS (not sure which version.)

I have this code:

n.tests.7 <- 3 ## for example
trailing.7.pos.percent <- 12  ## for example
trailing.7.message <-
ifelse( n.tests.7 > 0,
paste("In the past seven days,", n.tests.7, "test results have
been reported, of which", trailing.7.pos.percent, "\\% were positive"),
paste("No test results have been reported from these labs in
the past seven days.") )

Desired outcome in the resulting .tex file is "In the past seven days, 3
test results have been reported, of which 12\% were positive."

But I get "In the past seven days, 3 test results have been reported, of
which 12\\% were positive." Which, when compiled in pdflatex,
unsurprisingly cuts off the sentence at 12

Replacing, in the .Rnw code, the \\% with \% , yields an R error message:

Error: '\%' is an unrecognized escape in character string starting ""\%"

Grateful for any help.

--Chris Ryan

[[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] prop.trend.test

2023-09-08 Thread Ebert,Timothy Aaron
Say I have one machine that produces 15 million widgets per day. Every day a 
few widgets are defective. Is the proportion increasing?
The data analyst needs to know what time span is of interest. I assume that 
there is some day-to-day variability. Is today's defect rate greater or less 
than yesterday's rate is not a trend. However, there might also be other 
trends. 4th shift might have a higher rate than 2nd shift, or within a shift 
the rate may change as workers tire or get breaks.

I might try the PooledInfRate package. It calculates a proportion defective and 
a 95% confidence interval. Do the intervals overlap?
I might  try being selective. If the rate changes over the week, then the 
weekly cycle may obscure an underlying trend. For the last year, has the rate 
increased using only data from Monday?
The question gets more complicated if there are multiple production lines and 
locations. High worker turnover may also be an issue.


Tim

-Original Message-
From: R-help  On Behalf Of Rui Barradas
Sent: Friday, September 8, 2023 6:53 AM
To: peter dalgaard ; Thomas Subia 
Cc: R. Mailing List 
Subject: Re: [R] prop.trend.test

[External Email]

Às 10:06 de 08/09/2023, peter dalgaard escreveu:
> Yes, this was written a bit bone-headed (as I am allowed to say...)
>
> If you look at the code, you will see inside:
>
>  a <- anova(lm(freq ~ score, data = list(freq = x/n, score = 
> as.vector(score)),
>  weights = w))
>
> and the lm() inside should give you the direction via the sign of the 
> regression coefficient on "score".
>
> So, at least for now, you could just doctor a copy of the code for
> your own purposes, as in
>
>   fit <- lm(freq ~ score, data = list(freq = x/n, score = as.vector(score)),
>  weights = w)
>   a <- anova(fit)
>
> and arrange to return coef(fit)["score"] at the end. Something like
> structure(... estimate=c(lpm.slope=coef(fit)["score"]) )
>
> (I expect that you might also extract the t-statistic from
> coef(summary(fit)) and find that it is the signed square root of the
> Chi-square, but I won't have time to test that just now.)
>
> -pd
>
>> On 8 Sep 2023, at 07:22 , Thomas Subia via R-help  
>> wrote:
>>
>> Colleagues,
>>
>> Thanks all for the responses.
>>
>> I am monitoring the daily total number of defects per sample unit.
>> I need to know whether this daily defect proportion is trending upward (a 
>> bad thing for a manufacturing process).
>>
>> My first thought was to use either a u or a u' control chart for this.
>> As far as I know, u or u' charts are poor to detect drifts.
>>
>> This is why I chose to use prop.trend.test to detect trends in proportions.
>>
>> While prop.trend.test can confirm the existence of a trend, as far as
>> I know, it is left to the user to determine what direction that trend is.
>>
>> One way to illustrate trending is of course to plot the data and use
>> geom_smooth and method lm For the non-statisticians in my group, I've found 
>> that using this method along with the p-value of prop.trend.test, makes it 
>> easier for the users to determine the existence of trending and its 
>> direction.
>>
>> If there are any other ways to do this, please let me know.
>>
>> Thomas Subia
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thursday, September 7, 2023 at 10:31:27 AM PDT, Rui Barradas 
>>  wrote:
>>
>>
>>
>>
>>
>> Às 14:23 de 07/09/2023, Thomas Subia via R-help escreveu:
>>>
>>> Colleagues
>>>
>>> Consider
>>> smokers  <- c( 83, 90, 129, 70 )
>>> patients <- c( 86, 93, 136, 82 )
>>>
>>> prop.trend.test(smokers, patients)
>>>
>>> Output:
>>>
>>> Chi-squared Test for Trend inProportions
>>>
>>> data:  smokers out of patients ,
>>>
>>> using scores: 1 2 3 4
>>>
>>> X-squared = 8.2249, df = 1, p-value = 0.004132
>>>
>>> # trend test for proportions indicates proportions aretrending.
>>>
>>> How does one identify the direction of trending?
>>> # prop.test indicates that the proportions are unequal but doeslittle 
>>> to indicate trend direction.
>>> All the best,
>>> Thomas Subia
>>>
>>>
>>>  [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://st/
>>> at.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl
>>> .edu%7Cc652dfff973549a790db08dbb059e5da%7C0d4da0f84a314d76ace60a6233
>>> 1e1b84%7C0%7C0%7C638297672399811965%7CUnknown%7CTWFpbGZsb3d8eyJWIjoi
>>> MC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C
>>> %7C%7C=RLmEonNbUSLwfvHjWylq75aNjrfQ5nNlRocDb98HQa4%3D
>>> =0 PLEASE do read the posting guide
>>> http://www/
>>> .r-project.org%2Fposting-guide.html=05%7C01%7Ctebert%40ufl.edu%
>>> 7Cc652dfff973549a790db08dbb059e5da%7C0d4da0f84a314d76ace60a62331e1b8
>>> 4%7C0%7C0%7C638297672399811965%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wL
>>> jAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7
>>> 

[R-es] Orden en los polígonos de Voronoi

2023-09-08 Thread Isidro Hidalgo Arellano via R-help-es
Buenos d�as:
La funci�n st_voronoi() del paquete sf desordena los pol�gonos resultantes. La 
he usado con los puntos de los municipios de Espa�a y el pol�gono de Voronoi n� 
1 no es el correspondiente al primer n�cleo de poblaci�n.
�Sab�is alguna forma de mantener el orden original, seg�n los puntos usados?
He intentado relacionar los pol�gonos resultantes con cada punto usado. Esto en 
teor�a es posible, ya que el punto es el centroide del pol�gono, pero no doy 
con la tecla:

library(sf)
library(mapSpain)
library(tidyverse)
clm <- esp_get_prov_siane("Castilla-La Mancha", epsg = 3035)
municipios_esp <- esp_get_munic_siane(year = 2019, epsg = 3035) # AVISO: tarda 
un poco
nucleos_esp <- esp_get_capimun(year = 2022, epsg = 3035)
voronoi_esp <- nucleos_esp |>
  st_union() |>
  st_voronoi()

Como siempre, mil gracias...

Isidro Hidalgo Arellano
Observatorio del Mercado de Trabajo
Junta de Comunidades de Castilla - La Mancha


[[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] prop.trend.test

2023-09-08 Thread Rui Barradas

Às 10:06 de 08/09/2023, peter dalgaard escreveu:

Yes, this was written a bit bone-headed (as I am allowed to say...)

If you look at the code, you will see inside:

 a <- anova(lm(freq ~ score, data = list(freq = x/n, score = 
as.vector(score)),
 weights = w))

and the lm() inside should give you the direction via the sign of the regression 
coefficient on "score".
  
So, at least for now, you could just doctor a copy of the code for your own purposes, as in


  fit <- lm(freq ~ score, data = list(freq = x/n, score = as.vector(score)),
 weights = w)
  a <- anova(fit)
  
and arrange to return coef(fit)["score"] at the end. Something like structure(... estimate=c(lpm.slope=coef(fit)["score"]) )


(I expect that you might also extract the t-statistic from coef(summary(fit)) 
and find that it is the signed square root of the Chi-square, but I won't have 
time to test that just now.)

-pd


On 8 Sep 2023, at 07:22 , Thomas Subia via R-help  wrote:

Colleagues,

Thanks all for the responses.

I am monitoring the daily total number of defects per sample unit.
I need to know whether this daily defect proportion is trending upward (a bad 
thing for a manufacturing process).

My first thought was to use either a u or a u' control chart for this.
As far as I know, u or u' charts are poor to detect drifts.

This is why I chose to use prop.trend.test to detect trends in proportions.

While prop.trend.test can confirm the existence of a trend, as far as I know, 
it is left to the user
to determine what direction that trend is.

One way to illustrate trending is of course to plot the data and use 
geom_smooth and method lm
For the non-statisticians in my group, I've found that using this method along 
with the p-value of prop.trend.test, makes it easier for the users to determine 
the existence of trending and its direction.

If there are any other ways to do this, please let me know.

Thomas Subia












On Thursday, September 7, 2023 at 10:31:27 AM PDT, Rui Barradas 
 wrote:





Às 14:23 de 07/09/2023, Thomas Subia via R-help escreveu:


Colleagues

Consider
smokers  <- c( 83, 90, 129, 70 )
patients <- c( 86, 93, 136, 82 )

prop.trend.test(smokers, patients)

Output:

Chi-squared Test for Trend inProportions

data:  smokers out of patients ,

using scores: 1 2 3 4

X-squared = 8.2249, df = 1, p-value = 0.004132

# trend test for proportions indicates proportions aretrending.

How does one identify the direction of trending?
# prop.test indicates that the proportions are unequal but doeslittle to 
indicate trend direction.
All the best,
Thomas Subia


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

Hello,

By visual inspection it seems that there is a decreasing trend.
Note that the sample estimates of prop.test and smokers/patients are equal.


smokers  <- c( 83, 90, 129, 70 )
patients <- c( 86, 93, 136, 82 )

prop.test(smokers, patients)$estimate
#>prop 1prop 2prop 3prop 4
#> 0.9651163 0.9677419 0.9485294 0.8536585

smokers/patients

#> [1] 0.9651163 0.9677419 0.9485294 0.8536585

plot(smokers/patients, type = "b")



Hope this helps,

Rui Barradas

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



Hello,

Actually, the t-statistic is not the signed square root of the X-squared 
test statistic. I have edited the function, assigned the lm fit and 
returned it as is. (print.htest won't print this new list member so the 
output is not cluttered with irrelevant noise.)



smokers  <- c( 83, 90, 129, 70 )
patients <- c( 86, 93, 136, 82 )

edit(prop.trend.test, file = "ptt.R")
source("ptt.R")

# stats::prop.trend.test edited to include the results
# of the lm fit and saved under a new name
ptt <- function (x, n, score = seq_along(x))
{
  method <- "Chi-squared Test for Trend in Proportions"
  dname <- paste(deparse1(substitute(x)), "out of", 
deparse1(substitute(n)),

 ",\n using scores:", paste(score, collapse = " "))
  x <- as.vector(x)
  n <- as.vector(n)
  p <- sum(x)/sum(n)
  w <- n/p/(1 - p)
  a <- anova(fit <- lm(freq ~ score, data = list(freq = x/n, score = 
as.vector(score)),

   weights = w))
  chisq <- c(`X-squared` = a["score", "Sum Sq"])
  structure(list(statistic = chisq, parameter = c(df = 1),
 p.value = pchisq(as.numeric(chisq), 1, lower.tail = 
FALSE),

 method = method, data.name = dname
 , lmfit = 

Re: [R] prop.trend.test

2023-09-08 Thread peter dalgaard
Yes, this was written a bit bone-headed (as I am allowed to say...)

If you look at the code, you will see inside:

a <- anova(lm(freq ~ score, data = list(freq = x/n, score = 
as.vector(score)), 
weights = w))

and the lm() inside should give you the direction via the sign of the 
regression coefficient on "score".
 
So, at least for now, you could just doctor a copy of the code for your own 
purposes, as in

 fit <- lm(freq ~ score, data = list(freq = x/n, score = as.vector(score)), 
weights = w)
 a <- anova(fit)
 
and arrange to return coef(fit)["score"] at the end. Something like 
structure(... estimate=c(lpm.slope=coef(fit)["score"]) )

(I expect that you might also extract the t-statistic from coef(summary(fit)) 
and find that it is the signed square root of the Chi-square, but I won't have 
time to test that just now.)

-pd

> On 8 Sep 2023, at 07:22 , Thomas Subia via R-help  
> wrote:
> 
> Colleagues,
> 
> Thanks all for the responses. 
> 
> I am monitoring the daily total number of defects per sample unit. 
> I need to know whether this daily defect proportion is trending upward (a bad 
> thing for a manufacturing process).
> 
> My first thought was to use either a u or a u' control chart for this.
> As far as I know, u or u' charts are poor to detect drifts. 
> 
> This is why I chose to use prop.trend.test to detect trends in proportions.
> 
> While prop.trend.test can confirm the existence of a trend, as far as I know, 
> it is left to the user
> to determine what direction that trend is. 
> 
> One way to illustrate trending is of course to plot the data and use 
> geom_smooth and method lm
> For the non-statisticians in my group, I've found that using this method 
> along with the p-value of prop.trend.test, makes it easier for the users to 
> determine the existence of trending and its direction.
> 
> If there are any other ways to do this, please let me know.
> 
> Thomas Subia
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Thursday, September 7, 2023 at 10:31:27 AM PDT, Rui Barradas 
>  wrote: 
> 
> 
> 
> 
> 
> Às 14:23 de 07/09/2023, Thomas Subia via R-help escreveu:
>> 
>> Colleagues
>> 
>>Consider
>> smokers  <- c( 83, 90, 129, 70 )
>> patients <- c( 86, 93, 136, 82 )
>> 
>>prop.trend.test(smokers, patients)
>> 
>>Output:
>> 
>>Chi-squared Test for Trend inProportions
>> 
>>data:  smokers out of patients ,
>> 
>> using scores: 1 2 3 4
>> 
>> X-squared = 8.2249, df = 1, p-value = 0.004132
>> 
>># trend test for proportions indicates proportions aretrending.
>> 
>>How does one identify the direction of trending?
>># prop.test indicates that the proportions are unequal but doeslittle to 
>> indicate trend direction.
>> All the best,
>> Thomas Subia
>> 
>> 
>> [[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.
> Hello,
> 
> By visual inspection it seems that there is a decreasing trend.
> Note that the sample estimates of prop.test and smokers/patients are equal.
> 
> 
> smokers  <- c( 83, 90, 129, 70 )
> patients <- c( 86, 93, 136, 82 )
> 
> prop.test(smokers, patients)$estimate
> #>prop 1prop 2prop 3prop 4
> #> 0.9651163 0.9677419 0.9485294 0.8536585
> 
> smokers/patients
> 
> #> [1] 0.9651163 0.9677419 0.9485294 0.8536585
> 
> plot(smokers/patients, type = "b")
> 
> 
> 
> Hope this helps,
> 
> Rui Barradas
> 
> __
> 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.