# rstudio

1. ### Summarize by group the maximum amount of time a range of values continuously occurred in R

Say I have a dataframe that looks like this (wasn't sure how to actually rep. this data, given its size): > head(df) yr mo day time sal site 2021 8 1 0000 26.614 14 2021 8 1 0015 25.724 14 2021 8 1 0030 25.739 14 2021 8 1...
2. ### What is the best T test to use for my data?

Hi, I'm trying to work out the correct non parametric T test to use for my data. My data is made of two large groups. Each value in the first group has a corresponding later value e.g. it is showing the chance in frequency from point 1 to point 2 over time, there is many different points for...
3. ### How to calculate partial residuals by hand?

Code for GLM Poisson regression (R): library(datasets) mydata <- warpbreaks poisson_mod <- glm(breaks ~ wool + tension, mydata, family = poisson()) Gives: Call: glm(formula = breaks ~ wool + tension, family = poisson(link = "log"), data = mydata) Coefficients: (Intercept) woolB...
4. ### Interpreting Results of Monte Carlo Simulation (R)

Hello, I have conducted a Monte Carlo simulation in R based on the guidelines below and I am struggling to interpret my results. Consider the following data-generating process Y = β1 × X + u 1. Simulate 1000 samples of size n = 100 with β1 = 2, X ∼ N(100,15) and u ∼ N(0,8). 2. In each...
5. ### Multinomial Regression & Multi-colinearity

Hi All, Question regarding multi-collinearity and multinomial logistic regression. I am trying to generate a model that can determine the winning probabilities of each horse in race. Quite simple, my data has 1 denoting Win or 0 lose for each horse in my collected data. I obviously have a...
6. ### How to adjust specific tabletext font to bold?

Hi all, I wrote a script using the "forestplot" package. I want to group the variables in certain categories, which I would like to show in bold, in order to accentuate those categories. How can i adjust my script, so that only certain rows, i.e Risk factor OR (95% CI), patient characteristics...
7. ### Help with testing three variables (non-metrical) perhaps GEE

Hi, I ran a survey (n=38) and now I'm trying to analyze one hypothesis with Rstudio: H4: People workout more when working from home, than in office. I'm trying to combine two items to test this hypothesis. 1. sporting activity (frequency per week; ordinal scale) in 4 different periods...
8. ### Dynamic regression

Hi everybody, i would be happy if you could help me with my statistics =) I do a dynamic model to check the influence of the weekdays/weekend behavior in mobilitychanges based on google data. For this i use R-Studio. I tried as followed: dynlm(y_w ~ L(y_w,1) + L(D,0)) y_w is my data of the...
9. ### Use of the g-formula to estimate the x change after x years in x sample in R

Hi guys, New here. Terrible at stats and made a terrible decision to take stats module and have never felt so stupid. I know R well but not for pure stats stuff like this and more for general data analysis. I need to do an analysis in R for the above. Along with answering: if had nobody...
10. ### Conjoint analysis: bias due to no-choice option and linear attribute

At the moment I am analysing survey data using Bayesian estimation in R (bayesm package) For my analysis, I have included a no-choice option (NoneOpt) that is coded as a series of zeros. However, I also have a price attribute (Delivery.costs). What I actually want to do is keep the price...
11. ### Help with R code to produce proportions of sample means above one sigma

Hi everyone, I'm struggling with the following question for an R assignment: Demonstrate understanding of the Central Limit Theorem, using R, by showing how the distribution of the sample mean changes according to sample size. Consider a Poisson distribution with λ = 1.5. Generate samples of...
12. ### 3 IV, 4 DVs, and a partridge in ...

I am going back and forth between which data analysis would be best to use for my study. Any thoughts and or recommendations would be greatly appreciated. I am conducting research into the impacts of three independent variables; speaker type, task difficulty, and task format, on the oral speech...
13. ### Multivariate analysis for Medicine Thesis

Hi, I am writing my thesis for medicine about postoperative complications of a disease (IBD). The dependent variable in this case is whether the patients had a post-operative complication or not (binary) within 30 days of their operation. The sample size for my study is n = 62. I have...
14. ### RStudio CSV Import of incorrectly formatted data

Hi everyone, new to the site, hope I'm posting in the right place. Just started using R after a recommendation from my uni tutor in order to process the data from my dissertation experiment. I'm most used to Matlab and the transition has seemed pretty easy so far. I've just finished my...
15. ### Error in mlogit package: system is computationally singular

I have a data set that is formatted according to mlogit's standards using mlogit.data command in Rstudio. Trip SevereEarthquake Night Age Mode 1.NTG 1 0 0 18 FALSE 1.TGNV 1 0 0 18...
16. ### Sphericity with unequal sample sizes

Hello, I want to do a repeated measures anova in R on a data set consisting of four treatments on subjects, over 4 weeks. However, in week 3 I am missing data from a third of the subjects. Does anyone know how I can test for sphericity in R with these missing data points? Many thanks in...
17. ### [R] Changing 2 Numeric Variables to 1 Categorical Variable in R?

I am a finance student and have been playing around in R the past couple of weeks (Rookie here..). QUESTION: I have two numeric variables: A and B. And I want turn these in one cathegorical variable C. C takes the following values: 1 if A and B both score top decile – or quintile of the...
18. ### Arguments imply differing number of rows: 1, 0

I am trying to generate a cdf plot by using ggplot and have looked at some examples online. However when I try to replicate it I get the following error: "arguments imply differing number of rows: 1, 0" I made a search and it seems from what I gather the nrows!=ncol and that doesn't work for a...
19. ### Forecasting/Future prediction assistance

Hi guys, I've got a bit of advertising data here and I'd like to make a model out of it which can predict future events. So I have the amount of money spent, the number of billboards we've got and how many people we think have seen the billboard. We also have the number of walk ins we...
20. ### Evaluation of the most suitable model between LASSO and Forward stepwise selection.

Hello, please take into account this: I'm a beginner :) I need to assess which of the two following specifications of a model is more suitable and explain it. This is what I obtained running properly on R the tools I had: FORWARD STEPWISE SELECTION: LASSO REGRESSION: This shows the...