0
$\begingroup$

I'm trying to model Mean Opinion Scores (MOS) about image quality, based on an image data base. The data base has 3000 images, it has 25 original images, 24 distortions of each one and 5 levels of distortion for each distortion type (25*24*5 = 3000). The MOS is a real number between 0 and 9.

The MOS distribution doesn't seem to be normal since according to its histogram it is not symmetric.

I think a Beta distribution would be fine, since it is negative skew. Do you agree with me? What other distribution could be used?

What confuses me is that the explanatory variables are categorical,

Image: it is a number in the range 1, 2, ... up to 25

Distortion: it is a number in the range 1, 2, ... up to 24

Level: it is a number in the range 1, 2, ... up to 5

I'm not sure how to work with categorical variables in a General Linear Model.

I don't know what link function use and why neither.

I wrote this code in python to fit the model:

# the data were previously loaded in a numpy array called data_array

X = np.empty((3000, 3))

X[:,0] = data_array[:, 0].astype(int) # image
X[:,1] = data_array[:, 1].astype(int) # distortion
X[:,2] = data_array[:, 2].astype(int) # level

mos = data_array[:, 3] # mos

X = sm.add_constant(X, prepend=False) # it appends a column of 1's

model = sm.GLM(mos, X, family=sm.families.Gamma())

results = model.fit()

print(results.summary())

I used a Gamma distribution because Beta distribution is not available in Python... do you know how to get a Beta distribution from another distribution?... or maybe I should try with R not Python...

Any kind of help is welcome.

Thanks you very much!

Best regards

Lucy

$\endgroup$
2
  • $\begingroup$ Using categorical variables to explain the response is very common in multivariate regression. What exactly are you not getting? Is your question specifically about categorical variables in GLMs? Or just in regressions in general? (Also, I believe you mean Generalized Linear Model, not General Linear Model, which is not the same thing.) $\endgroup$
    – AdmiralWen
    Commented Jun 14, 2017 at 13:46
  • $\begingroup$ I want to know if I can make a GLM in python using a beta distribution and how would be the code? how do I indicate to the software that the variables are categorical? $\endgroup$ Commented Jun 14, 2017 at 20:20

1 Answer 1

1
$\begingroup$

Regarding your issue with categorical variables:

I guess it's not such a big deal to add categorical var into regression if your categorical variable is ordered (so that you can say that the increase variable means something). I've never worked with something like that, but I think with "distortion" it should work.

Once categories are something like "levels" and they cannot be ordered, I think it will make more sense to split this variable into the set of dummies (leaving one category as a baseline).

$\endgroup$
1
  • $\begingroup$ Actually the 1 to 24 distortions are not ordered, they could be in any order and it would be the same, they are 24 totally different types of distortions. The levels from 1 to 5 are ordered, for example distortion 15 with level 4 is more contaminated than distortion 15 with level 2. $\endgroup$ Commented Jun 14, 2017 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.