[R] poLCA problem

2021-03-05 Thread Scott Colwell
Good morning everyone,

I am running into errors with poLCA as follows:

Error in round(mf) : non-numeric argument to mathematical function.

Here is what I have. Both variables are coded as 1, 2, 3

df <- as.data.frame(data)

items <- c("x1", "x2")  <- there are more variables but shortened for this
purpose

df2 <- df[items]

i <- cbind(x1, x2)~1

poLCA (i, df2, nclass=2, maxiter=100, nrep=10, verbose =TRUE)

It is after the poLCA that I get the error. Any thoughts on what is causing
this?

Thanks,

Scott

[[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] Quantitative Methods Workshops in May 2020

2020-04-06 Thread Scott Colwell
FORWARDED – The following message has been forwarded and is not related to the 
University of Guelph.

Apologies for the cross-posting.

Good morning everyone. We sincerely hope you are all keeping safe and healthy 
while we all endure this pandemic.

As a result of the restrictions on public gatherings, we are going to be 
delivering our May 2020 workshops via online live streaming now as opposed to 
face-to-face at McMaster University. We will be providing materials ahead of 
time for all participants and will still include time for individual 
consultation regarding your own data (which can be scheduled at the live-stream 
workshop).

Each workshop provides a hands-on opportunity to learn using both R (with 
R-Studio) and Mplus.

For further information and to register, please go to: 
https://workshops.enablytics.com/


[1] Introduction to Structural Equation Modeling

This one-day hands-on workshop covers various introductory topics in structural 
equation modeling with continuous and categorical variables. Topics include, 
assumptions and data considerations, model creation, identification, and 
evaluation, multiple regression vs path analysis, path analysis, testing direct 
and indirect effects, and confirmatory factor analysis. Examples will be 
demonstrated in both R (using R-Studio) and Mplus. Syntax and output for both 
programs will be provided for all examples covered in the workshop.

[2] Advanced Structural Equation Modeling

This one-day hands-on workshop covers various advanced topics in structural 
equation modeling with continuous and categorical variables. Topics include, 
model creation, identification, and evaluation, testing moderation, mediation 
and moderated mediation, multiple group modeling, handling missing data, 
measurement invariance and power analysis. Examples will be demonstrated in 
both R (using R-Studio) and Mplus. Syntax and output for both programs will be 
provided for all examples covered in the workshop.

[3] Growth Modeling

This one-day hands-on workshop covers various topics in growth modeling 
(longitudinal modeling) with continuous and categorical variables. Topics 
include, growth modeling without covariates, growth modeling with time 
invariant and varying covariates, centering points, piecewise growth modeling, 
missing data and power analysis. Examples will be demonstrated in both R (using 
R-Studio) and Mplus. Syntax and output for both programs will be provided for 
all examples covered in the workshop.

[4] Multilevel Modeling

This two day hands-on workshop covers various topics in multilevel modeling 
with continuous and categorical variables. Topics include, when multilevel 
analysis is necessary, multilevel regression, random slopes and cross-level 
effects, multilevel confirmatory factor analysis and the MIMIC model, 
multilevel path analysis, multilevel mediation and moderation, multilevel 
latent variable modeling, longitudinal data, and power analysis. Examples will 
be demonstrated in both R (using R-Studio) and Mplus. Syntax and output for 
both programs will be provided for all examples covered in the workshop.

Thank you,

Scott





[[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] Creating hanging bar plot in r from dplyr

2019-04-20 Thread Scott Colwell
That is perfect. Thanks!

--
Scott R. Colwell, PhD

On 2019-04-20, 1:23 PM, "Jeff Newmiller"  wrote:

Not really sure I understand what you want. Here is some code to 
consider:



library(ggplot2)
library(dplyr)
library(tidyr)

dta <- read.table( text =
"samp.N   RSQMRB_uc  MRB_sb  MRB_bp
  50  0.3  1.4237.6   37.6
  50  0.4  8.6143.1   43.1
  50  0.5  7.4131.6   31.6
  50  0.6  5.0621.5   21.5
  50  0.7  3.3814.1   14.1
  50  0.8 -1.075.16   5.16
100  0.3 -6.4140.3   40.3
100  0.4 -10.621.0   21.0
100  0.5 -9.0213.2   13.2
100  0.6 -9.855.14   5.14
100  0.7 -7.942.08   2.08
100  0.8 -4.811.28   1.28
", header = TRUE )
dta2 <- (   dta
 %>% mutate( samp.N = factor( samp.N )
   , RSQ = factor( RSQ )
   )
 %>% gather( Measure, value, -c( samp.N, RSQ ) )
 )

ggplot( dta2, aes( x = RSQ, y = value, fill = samp.N ) ) +
   geom_bar( stat = "identity", position = "dodge", colour = "black" ) +
   facet_wrap( ~ Measure, ncol = 1, scale = "free_y" ) +
   ylab( "" )




On Sat, 20 Apr 2019, Scott Colwell wrote:

> I am trying to figure out how to create a hanging bar plot from dplyr.
> I have used dplyr as follows:
> table4 <- cr %>%
>  group_by(samp.N, RSQ) %>%
>  summarize(
>MRB_uc = mean(CF.F1F2/0.40*100)-100,
>MRB_sb = mean(SBC.F1F2.Alpha/0.40*100) - 100,
>MRB_bp = mean(BPC.F1F2.Alpha/0.40*100) - 100
>  )
> which provides me with this:
>   samp.N   RSQ MRB_uc MRB_sb MRB_bp
>   
> 1 50   0.3   1.42  37.6   37.6
> 2 50   0.4   8.61  43.1   43.1
> 3 50   0.5   7.41  31.6   31.6
> 4 50   0.6   5.06  21.5   21.5
> 5 50   0.7   3.38  14.1   14.1
> 6 50   0.8  -1.07   5.16   5.16
> 7100   0.3  -6.41  40.3   40.3
> 8100   0.4 -10.6   21.0   21.0
> 9100   0.5  -9.02  13.2   13.2
> 10100   0.6  -9.85   5.14   5.14
> 11100   0.7  -7.94   2.08   2.08
> 12100   0.8  -4.81   1.28   1.28
> What I want to do is create a hanging bar plot with the x-axis being 
samp.N value by RSQ value. The bars are then values of MRB_uc, MRB_sb, and 
MRB_bp. Given some values are negative, some bars will be above zero and others 
below (hence the hanging bar plot)
> I don't have any code yet as I am completely unfamiliar with how to do 
this. Any suggestions would be really appreciated.
> Thank you!
> Scott
>
>
>
>
> --
> Scott R. Colwell, PhD
>
>
>   [[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.
>

---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
   Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
---


__
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] Creating hanging bar plot in r from dplyr

2019-04-20 Thread Scott Colwell
I am trying to figure out how to create a hanging bar plot from dplyr.
I have used dplyr as follows:
table4 <- cr %>%
  group_by(samp.N, RSQ) %>%
  summarize(
MRB_uc = mean(CF.F1F2/0.40*100)-100,
MRB_sb = mean(SBC.F1F2.Alpha/0.40*100) - 100,
MRB_bp = mean(BPC.F1F2.Alpha/0.40*100) - 100
  )
which provides me with this:
   samp.N   RSQ MRB_uc MRB_sb MRB_bp
   
1 50   0.3   1.42  37.6   37.6
 2 50   0.4   8.61  43.1   43.1
 3 50   0.5   7.41  31.6   31.6
 4 50   0.6   5.06  21.5   21.5
 5 50   0.7   3.38  14.1   14.1
 6 50   0.8  -1.07   5.16   5.16
7100   0.3  -6.41  40.3   40.3
 8100   0.4 -10.6   21.0   21.0
 9100   0.5  -9.02  13.2   13.2
10100   0.6  -9.85   5.14   5.14
11100   0.7  -7.94   2.08   2.08
12100   0.8  -4.81   1.28   1.28
What I want to do is create a hanging bar plot with the x-axis being samp.N 
value by RSQ value. The bars are then values of MRB_uc, MRB_sb, and MRB_bp. 
Given some values are negative, some bars will be above zero and others below 
(hence the hanging bar plot)
I don't have any code yet as I am completely unfamiliar with how to do this. 
Any suggestions would be really appreciated.
Thank you!
Scott




--
Scott R. Colwell, PhD


[[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] 2019 Spring Workshops using R

2019-04-13 Thread Scott Colwell
Apologies for any cross-postings.
Just a reminder that registration is open for four quantitative methods 
workshops in May of 2019. Each workshop features hands-on examples in Mplus and 
R, plus lots of opportunities to discuss the analysis for your own research.
For more information and to register, please see 
https://enablytics.com/workshop_events/
[1] Introductory Structural Equation Modeling - May 5, 2019
141 Adelaide Street West
Toronto, Ontario
M5H 3L5
This one-day hands-on workshop covers various introductory topics in structural 
equation modeling with continuous and categorical variables. Topics include, 
assumptions and data considerations, model creation, identification, and 
evaluation, multiple regression vs path analysis, path analysis, testing direct 
and indirect effects, and confirmatory factor analysis. Syntax and output for 
both Mplus and R will be provided for all examples covered in the workshop.
[2] Advanced Structural Equation Modeling - May 6, 2019
141 Adelaide Street West
Toronto, Ontario
M5H 3L5
This one-day hands-on workshop covers various advanced topics in structural 
equation modeling with continuous and categorical variables. Topics include, 
model creation, identification, and evaluation, testing moderation, mediation 
and moderated mediation, multiple group modeling, handling missing and messy 
data, measurement invariance and power analysis. Syntax and output for both 
Mplus and R will be provided for all examples covered in the workshop.
[3] Multilevel Modeling - May 7 and 8, 2019
141 Adelaide Street West
Toronto, Ontario
M5H 3L5
This two day hands-on workshop covers various topics in multilevel modeling 
with continuous and categorical variables. Topics include, when multilevel 
analysis is necessary, multilevel regression, random slopes and cross-level 
effects, multilevel confirmatory factor analysis and the MIMIC model, 
multilevel path analysis, multilevel mediation and moderation, multilevel 
latent variable modeling, longitudinal data, and power analysis. Syntax and 
output for both Mplus and R will be provided for all examples covered in the 
workshop.
[4] Growth Modeling - May 9 and 10, 2019
141 Adelaide Street West
Toronto, Ontario
M5H 3L5
This two-day hands-on workshop covers various topics in growth modeling 
(longitudinal modeling) with continuous and categorical variables. Topics 
include, growth modeling without covariates, growth modeling with time 
invariant and varying covariates, centering points, piecewise  growth modeling, 
autoregressive latent trajectory modeling (ALT


--
Scott R. Colwell, PhD, CStat, PStat


[[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] R packages for Mac Users

2016-02-23 Thread Scott Colwell

Hello,

Does anyone know if all the R packages that are available for Windows users are 
also available for Mac users? 

Thank you,

Scott

-- 
Scott R. Colwell, Ph.D.
Associate Professor, Dept. of Mkt/Cons Studies
Adjunct Professor, Dept. of Psychology
University of Guelph
Guelph, Ontario, Canada, N1G 2W1

__
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] Looping and break

2015-03-02 Thread Scott Colwell
Hello,

I apologies for bringing up next and break in loops given that there is so
much on the net about it, but I've tried numerous examples found using
Google and just can't seem to get this to work.

This is a simple version of what I am doing with matrices but it shows the
issue. I need to have the loop indexed as n to perform a calculation on the
variable total. But if "total" is greater than 8, it goes to the next loop
indexed "a".  For example, it does condition a = 1 for n = 1 to 50 but
within n if total is greater than 8 it goes to the next condition of a which
would be a = 2, and so on.

for (a in 1:3){
  
  if (a == 1) { b <- c(1:5) }
  if (a == 2) { b <- c(1:5) }
  if (a == 3) { b <- c(1:5) }
  
  for (n in 1:50){
  
 if (n > 15) next

 total <- 2*b
  
 if (total > 8) next

  }
}

Any help would be greatly appreciated.

Thanks,

Scott



--
View this message in context: 
http://r.789695.n4.nabble.com/Looping-and-break-tp4704093.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Saving Mean Relative Difference from all.equal()

2015-02-26 Thread Scott Colwell
I think I have one solution. Not very pretty though. Relies on the text not
changing at all.

as.numeric(gsub("Mean relative difference: ", "",
all.equal(cov2cor(ITEMCOV),cor(item.data))[2]))

Is there a better way?



--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-Mean-Relative-Difference-from-all-equal-tp4703905p4703908.html
Sent from the R help mailing list archive at Nabble.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] Saving Mean Relative Difference from all.equal()

2015-02-26 Thread Scott Colwell

Hello,

Does anyone know how to save the numeric value of the "mean relative
difference" when using the all.equal() command?

For example this:

all.equal(cov2cor(ITEMCOV),cor(item.data))

Gives:

[1] "Attributes: < Length mismatch: comparison on first 1 components >"
[2] "Mean relative difference: 0.01523708"   

I'd like to save the value 0.01523708 in a numeric format.

Thanks,




--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-Mean-Relative-Difference-from-all-equal-tp4703905.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Extracting Factor Pattern Matrix Similar to Proc Factor

2015-02-26 Thread Scott Colwell
Thanks everyone



--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-Factor-Pattern-Matrix-Similar-to-Proc-Factor-tp4703704p4703904.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Extracting Factor Pattern Matrix Similar to Proc Factor

2015-02-23 Thread Scott Colwell
Thanks David. What do you do when the input is a covariance matrix rather
than a dataset?



--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-Factor-Pattern-Matrix-Similar-to-Proc-Factor-tp4703704p4703719.html
Sent from the R help mailing list archive at Nabble.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] Extracting Factor Pattern Matrix Similar to Proc Factor

2015-02-23 Thread Scott Colwell
Hello,

I am fairly new to R and coming from SAS IML. I am rewriting one of my MC
simulations in R and am stuck on extracting a factor pattern matrix as would
be done in IML using Proc Factor.  

I have found the princomp() command and read through the manual but can't
seem to figure out how to save the factor pattern matrix.  I am waiting for
the R for SAS Users book to arrive. What I would use in SAS IML to get at
what I am looking for is:

PROC FACTOR Data=MODELCOV15(TYPE=COV) NOBS=1 N=16 CORR
OUTSTAT=FAC.FACOUT15;
RUN;

DATA FAC.PATTERN15; SET FAC.FACOUT15;
IF _TYPE_='PATTERN';
DROP _TYPE_ _NAME_;
RUN;

Would any SAS IML to R converts be able to help me with this?

Thanks,

Scott Colwell, PhD




--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-Factor-Pattern-Matrix-Similar-to-Proc-Factor-tp4703704.html
Sent from the R help mailing list archive at Nabble.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.