0

Fairly new to R (used for much simpler stuff), coming from a deeper SAS background

I have a Dataframe which contains multiple types of data, amongst which 5 ratios, used as factors in logistic regression.

The factors are then transformed using a logistic transformation, subject to parameters that are given.

I need to apply those parameters to a longer dataset to essentially apply that logistic model to my own dataset (This is for validation purposes, so the parameters have to be exactly applied).

The dataframe would look something like:

obs unique_identifier event Regressor_1 Regressor_2 ... Regressor_5 Obs_date
no          no       factor    no           no              no         date 

The dataset also has other columns, but lets keep it short.

Parameters are contained in a separate dataframe that looks like

Regressor  Slope  Sign  Mid-point  mean  deviation
Regressor1    ..   ..     ....      ...    ....
Regressor2

and so forth. What I need is to perform an operation so that I get:

Regressor1_Score = F(Regressor1, parameters in matrix)

What is the best way to get that in R? something like mapply? how can you specify that parameters (rows in 2nd df) have to be applied to relevant columns in first df?

r2evans
  • 141,215
  • 6
  • 77
  • 149
cc143
  • 23
  • 2
  • What's "F()"? Should we assume "no" means "some number"? Do your really have a dash inside one of your column names? What are you referring to when you use the term "parameters in matrix"? This question cries out for a [MCVE]. – IRTFM Jan 27 '20 at 22:07
  • F() is the logistic transformation function: Regressor_Score = (((1/(1+exp(Slope*(Mid_point-(Regressor)))))-mean)*50/std.dev) Yes no. means some number No, I don't have a dash it was meant to be an underscore The matrix displayed is a dataframe that holds the parameters needed to transform each number to the score for logistic transformation – cc143 Jan 28 '20 at 09:02
  • Without code or actual data objects, there is no way to know where you are getting stuck. At the moment this appears to be a request to get a mini-tutorial on R function creation rather than a focussed coding question, See: "How to create a great reproducible example in R": https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?r=SearchResults&s=1|988.0638. There are also "parallel" tutorials using R and SAS at the UCLA stats website: https://stats.idre.ucla.edu/other/dae/ – IRTFM Jan 28 '20 at 17:29

0 Answers0