Need help creating a Regression Chart

Hello, I'm new to R and statistics in general. I am trying to create a Regression Chart between two variables those being Reliten (Religious Affiliation) and Cappun ( Favoring or Opposing Capital Punishment on Murders) both of which are found in the GSS dataset.

I have my lm and my summarylm
summary(lm(reliten_numeric ~ cappun_numeric, data=gss))
lm(gss$reliten_numeric ~ gss$cappun_numeric)

but my scatterplot
scatterplot(reliten_numeric ~ cappun_numeric, data=gss)
comes up with this error:
\ 16x14 pseudoinverse used at 0.995
neighborhood radius 1.005
reciprocal condition number 1.4841e-15
There are other near singularities as well. 1.01
pseudoinverse used at 0.995
neighborhood radius 1.005
reciprocal condition number 0
There are other near singularities as well. 1.01
pseudoinverse used at 0.995
neighborhood radius 1.005
reciprocal condition number 0
There are other near singularities as well. 1.01
pseudoinverse used at 0.995
neighborhood radius 1.005
reciprocal condition number 6.2844e-16
There are other near singularities as well. 1.01
pseudoinverse used at 0.995
neighborhood radius 1.005
reciprocal condition number 1.4841e-15
There are other near singularities as well. 1.01

How do I fix this or create a usable chart?

Hi Alexander, welcome!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

Since we don't know from where are you getting the gss dataset, I have made this example with the iris built-in dataset.

library(ggplot2)
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) +
    geom_smooth(method = "lm") +
    geom_point()

Created on 2019-04-08 by the reprex package (v0.2.1.9000)

1 Like

The GSS dataset comes from the library poliscidata

There are no reliten_numeric or cappun_numeric variables in gss dataset, how have you generated this variables? Again, if you want more specific help, please post a reproducible example for your question; otherwise try to adapt the above generic answer to your own data.

library(poliscidata)
library(dplyr)

gss %>% 
    select(starts_with("reliten"), starts_with("cappun")) %>% 
    names()
#> [1] "reliten"  "reliten2" "cappun"
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.