[R] Scripting Problem--Linear Regression Using Logit of the Response Variable

Sarah Goslee sarah.goslee at gmail.com
Fri Jan 8 18:07:38 CET 2016


>From a basic R syntax perspective, you're missing several commas, and
you don't specify your data. You also have a substantial problem with
parenthesis matching, with 3 ( and 4 )

adjust is an argument to logit(), and I'm assuming na.action is an
argument to lm().

>> EvacLM <- lm((logit(sharer_prob) ~ sympathy + trust + fear + greed) adjust=TRUE) na.action=NULL)

     EvacLM <- lm(logit(sharer_prob, adjust=TRUE) ~ sympathy + trust +
fear + greed, na.action=NULL, data=data)

If this is foreign to you, you should probably go read one of the many
good intro to R lessons online.

Sarah

On Thu, Jan 7, 2016 at 3:22 PM, John, Larry <Larry.John at anser.org> wrote:
> Dear fellow citizens of the R-verse,
>
> I'm a non-quant analyst trying to do some statistical analyses on a large data set unimaginatively named "data."
>
>   sympathy trust fear greed sharer_prob
> [1]      3     2    0     0    0.669593
> [2]      2     1    2     3    0.669593
> [3]      2     2    2     3    0.494675
> [4]      2     2    1     2    0.494675
> [5[      2     2    2     0    0.556837
> [6]      2     2    1     1    0.556837
>
> "sharer_prob" is the continuous dependent variable with values 0 > sharer_prob > 1, so I know need to run a logit transformation before I can do any linear regressions to study the main and interaction effects of the four independent variables.
>
> I've loaded "car" and tried for several hours to create a one-line script that will give me the overall linear model, but keep having problems. It seems to me that something like the following should work
>
>
>> EvacLM <- lm((logit(sharer_prob) ~ sympathy + trust + fear + greed) adjust=TRUE) na.action=NULL)
>
> But R politely tells me I've gotten something wrong:
>
>
> Error: unexpected symbol in "EvacLM <- lm((logit(sharer_prob) ~ sympathy + trust + fear + greed) adjust"
>
> I'm hoping one of you can spot and help me correct my mistake-I sure can't figure it out.
>
> Thanks for any help you can offer!
>
> Larry John
> Principal Analyst
> ANSER (www.anser.org)

-- 
Sarah Goslee
http://www.numberwright.com



More information about the R-help mailing list