Questions tagged [r]

Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer, & (b) is not *just* about how to use `R`.

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

how can you add the theoretical distribution to qqmath() output? [closed]

I would like to add a dotted line to represent the theoretical distribution in the output of qqmath(). What I have looks like this: ...
0
votes
0answers
9 views

Modelling of time-varying predictors in multilevel growth models in R

I am interested in the modelling of time-varying predictors in a multilevel growth model in R. Specifically, I am working with three-level data (measures collected across four timepoints (0,12,18,24 ...
1
vote
0answers
12 views

How can I weigh IPTW weight on data

how to calculate manually propensity score weights for multinomial treatments where one of them is baseline From the above question, I wonder how I can modify the original data with weight from IPTW. ...
0
votes
1answer
47 views

Does my ACF and PACF suggest no random noise?

I have 77 observations in my time series data which I obtained from the tsdl library in R. I have also reduced the time window. The data is quarterly average earnings. ...
1
vote
0answers
33 views

Which fit-line below is better in R

Please take a look at the below code: temperature.txt: time temperature 0 100 1 82 2 60 3 50 4 40 5 32 6 28 7 20 ...
1
vote
1answer
36 views

Calculating Sample Size For Multiple Groups (in R)

I am working with the R programming language. Suppose I have 1000 patients in a medical study, and I want to take measurements on these 1000 patients. 500 patients in Group A 250 patients in Group B ...
0
votes
0answers
13 views

How splineDesign in R creates design matrix of splines [closed]

I'm trying to gain insight into regression splines. Reading ISLR and ESLR by Trevor Hastie, looks like I understand the main idea for regression splines. I'd like to see how it works in code. I found ...
0
votes
0answers
15 views

Potential issue in partial autocorrelation in smoothed data using centered moving average in R

I'm new to time series analysis. I finds that if the data is smoothed by centered-moving average, its ACF will becomes significant(which is understandable), while its PACF will have peak at the lag ...
0
votes
0answers
49 views

How to "characterize" clusters (e.g K means)

I ran the K-means clustering algorithm on the iris data using the R programming language: ...
0
votes
0answers
8 views

ACF plot of differenced and transformed data

I am analysing time series data from the tsdl packages (specifically data number 94), my target time series is the time series named "real". I have shortened the time from to 1956 to 1975. <...
3
votes
1answer
45 views

Why does propensity score matching fail to estimate the true causal effect when OLS works?

Consider the following model (DAG), where D is the treatment (exposure) and Y1 is the outcome. To estimate the causal effect of <...
0
votes
1answer
28 views

R - How to compare two correlation matrices

I have two correlation matrices coming from the same variables (divided into two groups due to the presence of a particular event). I would compare these two matrices to show the differences in ...
3
votes
2answers
36 views

What is the expression for the confidence interval in a Kaplan-Meier curve?

In R, the survival fit object gives the non-parametric MLE for the survival curve via the Kaplan-Meier estimator. The fit also provides a confidence interval. What is the expression for the confidence ...
3
votes
1answer
52 views

SAS and R survival package have different confidence interval estimates. Why?

Hello I am learning about Survival Analysis and I noticed that SAS and R survival package produce different confidence interval estimates for the median Survival ...
0
votes
0answers
24 views

What test should I use for this count data?

My dataset consists of 3 variables: species, count, time period (current vs past). My research question is to compare the counts of each species in current period to the corresponding counts in past ...
1
vote
1answer
19 views

How to random generate a sample from {0,2} in R? [closed]

There are some solutions online on how to do a random generation of the discrete uniform distribution, but only on consecutive integers. Like : ...
0
votes
0answers
11 views

Is there an R package or MATLAB toolbox for estimating the spatiotemporal correlation structure of a dataset? [closed]

The CoSMoS package (https://cran.r-project.org/web/packages/CoSMoS/index.html) does some of what I want, or maybe the covatest package (https://cran.r-project.org/web/packages/covatest/index.html), ...
0
votes
0answers
9 views

Is that possible to align the Asterisks in correlation matrix [closed]

Can anyone know if there is a function for aligning asterisks in the correlation matrix using R. Thanks in advance.
0
votes
0answers
9 views

How can I get standard error using filt.mult.impute?

Now I am struggling with obtaining standard error of hazard ratio. There are some missing values, so that I am trying to use Hmisc::fit.mult.impute to perform multiple imputations. Here you can see ...
0
votes
0answers
17 views

Why does R give different value for one-sample K-S test?

I want to do K-S test in R. In this case, I use AdequacyModel and ks.test in R. My data: ...
0
votes
0answers
16 views

Reconcile fixest with reghdfe

I'm trying to replicate in R the results of a paper that uses the Stata reghdfe command but keep running into some issues. I've attached the dataset I'm using here (...
0
votes
0answers
20 views

Chi square test on proportions within hierarchical data [closed]

I have a dataframe such as : In that dataframe I have 4 groups (G1,G2,G3 & G4), and within each group I have 3 modalities (...
-1
votes
0answers
23 views

Test to compare 4 proportions in R

I would need help in order to perform a proportion comparison between 4 different modalities of one factor. Here is an example. I would like to compare the proportion of mother-to-child smoking ...
0
votes
0answers
35 views

using survival::pspline in GEE model in R

If I want to use a penalised spline basis for a predictor in a GEE model using R, is it possible to simply use the pspline function from the survival package? For example, ...
1
vote
0answers
19 views

fitting multilevel models for data that is both multiple membership and repeated measures

I have a longitudinal dataset with 5 repeated measures, where individuals are nested within counties and may have moved to a new county during the study period, e.g., ...
1
vote
0answers
12 views

effect size pre post change

The goal of my meta-analysis is to give insight in the percentage of treatment effect that would have been achieved as well when a person would be in the control group. This has been done in other ...
0
votes
0answers
10 views

Perform simple linear regression after Kendall correlation. Is that possible?

My raw-data (n=25) does not meet the assumption of normal distribution. Therefore, I want to do correlation matrix analysis with non-parametric Kendall tau correlation. But there is a linear ...
1
vote
1answer
39 views

Inverse functions for GAM

I would like to get the inverse function of my GAM. Here is my modeling code: ...
1
vote
0answers
16 views

Prediction of future dividend dates and dividend amounts in R [duplicate]

I have the dividends data of a company from 1987 to 2021. Using this data, I want to predict the future dividend dates for the next 5 years. Also, I want to predict the future dividend amounts this ...
0
votes
0answers
18 views

Noise in simulating logistic regression model

I would like to simulate data for logistic regression model as follows, ...
1
vote
1answer
27 views

Multi-state Cox models: different formulas for different transitions?

I'm using coxph from Therneau et al's survival package to model a multi-state system. Transitions include: Baseline -> ...
1
vote
0answers
27 views

The length of spectral density is longer than the data using spectrum() in R

I'm using spectrum(method = "pgram") in R to calculate the spectral density in my time series. spectrum() returns the spectral density for each frequency(from 1/n, 2/n to 1/2, n is the time ...
2
votes
1answer
39 views

Is my time series exhibiting stationarity?

I'm a beginner in time series analysis so I'm uncertain whether or not this data is stationary according to the ACF plot; I can observe a fast decay but on the other hand, a lot of the lines exceed -0....
0
votes
0answers
17 views

Prediction of future dividend dates and dividend amounts in R

I have the dividends data of a company from 1987 to 2021. Using this data, I want to predict the future dividend dates for the next 5 years. Also, I want to predict the future dividend amounts this ...
1
vote
1answer
18 views

Proportion comparaison between 4 modalities of one factor in R (chi2?) [closed]

I would need help in order to perform a proportion comparison between 4 different modalities of one factor. Here is an example. I would like to compare the proportion of mother-to-child smoking ...
-1
votes
0answers
22 views

Good online R tidyverse course for beginners? [closed]

I have few students who would like to learn R tidyverse. Could anyone recommend a good R tidyverse course for beginners? For example, the introduction of Rstudio, R basic calculations, data ...
2
votes
1answer
125 views

I have log transformed my data in R, but I want to find out what the 'original' unlogged value would be

I have a binomial glm modelling the probability of the occurrence of otter roadkill hotspots. My data were not normally distributed therefore to adhere to model assumptions I log transformed all of my ...
1
vote
1answer
31 views

Find r-squared of points around an x=y line (R)

I have some data I obtained from a lab experiment that shows the theoretical value of variable A, against its actual, experimentally derived value, for a range of variable A. I've plotted the data as ...
0
votes
0answers
36 views

Which trend has a better fit?

I have a time series data with 2 trend lines plotted; the red implies polynomial trend fitting while the black line is obtained from lowess (locally weighted smoothing). I'm not sure which trend line ...
0
votes
0answers
22 views

Is that possible to do simple linear regression with non-normal data set

I was wondering whether it's possible to do simple linear regression with non-normally distributed data. In my data set (n=25) some IVs have a normal distribution and some IVs do not show the normal ...
0
votes
1answer
46 views

mgcv - why does gam fit change so much with random effect

This is related to an earlier question which Gavin Simpson kindly answered: mgcv Error in gam. Model has more coefficients than data For these data I have 94 subjects and 123 observations and want to ...
0
votes
1answer
43 views

Linear Regression: Extremely Imbalanced Categorical Features

I am working on a Kaggle Housing Dataset (https://www.kaggle.com/c/house-prices-advanced-regression-techniques) to predict a house price using several regression techniques. For this project I am ...
0
votes
0answers
9 views

Multilevel repeated measures model specification in R. (nlme package)

I have interaction data from roughly 70 different teams. Each team took part in two exercises in which they had to cooperate to manage a spaceship. Each team completed both of the exercises. Because ...
0
votes
0answers
31 views

Does this seem like a seasonal effect? [duplicate]

I have tried to produce a seasonal fit onto a time series, and I got this result where all the amplitudes are consistent. Would you say this plot is valid or do I need to adjust it?
0
votes
0answers
30 views

Cox Proportional Hazards Model for panel data

I want to get the same results of implementing cox-box by R for this SAS code, ...
0
votes
1answer
53 views

Compositional data using R and difference between groups?

could you please help me in my research. I have a problem that can summarize: Is there a difference between stores in terms of the share of sales percentage in the 4th quarter. ...
0
votes
0answers
19 views

Sample size calculation for skewed data [closed]

I have a continuous outcome (0 - 100) that is quite skewed, I have attached a graph. I want to calculate the sample size to conduct a study. I am unsure as how to proceed. We are looking to recruit ...
0
votes
0answers
17 views

Infer Growth rate and Carrying capacity parameters using maximum likelihood in R

My apologies in advance if my question is naive. I intend to learn more about maximum likelihood inference and bayesian inference. I have read the theory, and now I want to enter the practice to get a ...
1
vote
1answer
33 views

Plot the cumulative intensity process survival analysis

Let T be an exponentially distributed survival time with hazard rate $\alpha(t) = 2$ for t > 0. Define $T = min(T,1)$ and $Delta = I(T \le 1)$. Let $\lambda(t)$ be the intensity process and $\...
0
votes
0answers
19 views

Is there a way to test for sig difference across 10 sample points

I have various elemental concentrations (Barium, Zinc, etc.) across 10 sample points in one lake. I want to know if I have significant differences in certain elements in certain sample points. Is ...