Stack Overflow » R
509 FOLLOWERS
This section of Stack Overflow is for asking questions about R programming language.
Stack Overflow » R
2m ago
How can I retrieve the p-value of R-squared of a simple lavaan model?
model <- sem('criterion ~ predictor1 + predictor2', data = data, missing = "FIML", fixed.x = FALSE, se = "BOOTSTRAP", bootstrap = 5000)
summary(model, standardize = FALSE, ci = TRUE, rsquare = T ..read more
Stack Overflow » R
1h ago
The figure was created using the Likert package; I need to know a way to change the bar names in the without-label section. Can someone please help ..read more
Stack Overflow » R
3h ago
I wrote a code for a simulation study to obtain average parameter estimates, their mean biases and mean square errors as sample size increases. The r code for the simulation study is presented below.
rm(list=ls())
library(stats4)
library(bbmle)
library(stats)
library(numDeriv)
library(Matrix)
##define PrWG pdf
PrWG_pdf<-function(theta,lambda,gamma,p,x){
(1-p)*(theta^2*x^(theta-1)+lambda*gamma*x^(gamma-1)*(1+x^theta))*(1+x^theta)^(-theta-1)*exp(-lambda*x^gamma)/(1-(p*(1+x^theta)^(-theta)*exp(-lambda*x^gamma)))^2
}
##define PrWG Quantiles
PrWG_quantile<-function(theta,lambda,gamma,p,u ..read more
Stack Overflow » R
4h ago
I'm trying to merge/join the two dataframes df and df2.
df was generated from a character vector that was cut at each position (4th, 10th, 12th, ... character) into string. The initial vector looked like this
vec1 <- paste(df$string, collapse = "").
df2 has name that correspond to some of the characters in vec1. For instance, the third and fifth characters in vec1 are P and A, and their names are pear and apple, respectively.
df <- data.frame("position" = c(4, 10, 12, 20, 27, 30),
"string" = c("MPPA", "APARLA", "LA", "LGLGLWLG", "ALAGGPG", "RGC"))
df2 <- data.frame("char ..read more
Stack Overflow » R
5h ago
I am testing for a difference in variance in two groups with a F test and now want to check beta. In the past I used the OC curves from Edwin Crow's "Statistics Manual" Chart VIII.
For example lambda = sd1/sd2 = 3, n=7 both groups, indicates beta ~0.2 on the chart (power = 80%). text
Using the package pwrss:
power.f.test(ncp = 3, df1 = 7, df2 = 7, alpha = 0.05) power ncp.alt ncp.null alpha df1 df2 f.crit 0.1092314 3 0 0.05 7 7 3.787044
i.e beta ~0.89
presumably ncp for the alternative hypothesis is not sd1/sd2. var1/var2 would be 9:
power.f.test(ncp = 9, df1 = 7, df2 = 7, alpha = 0.05) powe ..read more
Stack Overflow » R
5h ago
I want to draw pps sample from different zones. Every zone has its sample size. I have 2 data frames in rstudio. The first one contains the whole individuals, each individual belongs to a zone with a size variable.
The second data frame contains sample size of each zone.
First data frame (BD)
Individuals
Zone
size_variable
1
A
3
2
B
8
3
A
2
4
E
14
......
.......
.......
Second data frame (SZ)
Zone
Sample Size
A
4
B
6
C
7
D
10
......
.......
I turned the following code :
library(samplingbook)
library(dplyr)
library(readxl)
for (i in 1:nrow(SZ)) {
fo ..read more
Stack Overflow » R
6h ago
I am building a simulation in R using the simmer package.
The simulation models a restaurant where customers wait for their food after an order is placed.
Each order resource takes a different amount of time to use. Branch assigns a trajectory with a related timeout value depending on which resource was selected and records whether the resource used was digital or live for later reference. Note that this trajectory is incomplete on its own (explained later).
An order may have up to three types of products, each type having a different probability and taking a different amount of time to assemb ..read more
Stack Overflow » R
8h ago
I am running a multilevel growth curve model to examine predictors of social anhedonia (SA) trajectory through ages 12, 15 and 18. SA is a continuous numeric variable. The age variable (Index1) has been coded as 0 for age 12, 1 for age 15 and 2 for age 18. I am currently using a time varying predictor, stress (LSI), which was measured at ages 12, 15 and 18, to examine whether trajectory/variation in LSI predicts difference in SA trajectory. LSI is a continuous numeric variable. The data has been converted to long format with SA in 1 column, LSI in the other, ID in another and age in another co ..read more
Stack Overflow » R
9h ago
I have a function with the following form :
#include <cmath>
#include <RcppArmadillo.h>
#include <Rcpp.h>
// [[Rcpp::plugins(openmp)]]
#include <omp.h>
// [[Rcpp::depends(RcppParallel)]]
#include <RcppParallel.h>
using namespace Rcpp;
using namespace std;
NumericVector parallel_Calculation(Function &FUN,
const NumericVector ¶m)
{
...
#pragma omp parallel for
for(int k = 0; k < nb_Param; k++)
{
/* Using the FUN function to perform calculations */
}
...
}
I would like to use an arbitrary fun ..read more
Stack Overflow » R
9h ago
I'm trying to scrape CFB data from https://stathead.com/football/playerseasonfinder.cgirequest=1&match=player_season_combined&order_by=name_display_csk&year_min=2008&year_max=2024&positions%5B%5D=qb&draft_status=drafted&draft_pick_type=overall a paid website. I'm able to to login through R and obtain the primary links (list of players and their hyperlinks), but now I'm trying to navigate to each hyperlink and obtain the url of the "College Stats" hyperlink shown here on the resulting pages (example) https://www.profootballreference.com/players/Y/YounBr01.htm__hstc=2 ..read more