turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- GLM

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-08-2016 01:10 PM

Hi, I would like to create a model by using input x which is a matrix and output y which is a vector. I saw several examples for GLM but using input variables x1 ,x2,.. so on. But I have one variable x which is a matrix. Many thanks.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-08-2016 02:08 PM

If you have matrix, you may want to look at IML.

Otherwise, post a sample of what your data looks like.

Unless your matrix is Nx1, it's likely your data structure will support GLM.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-08-2016 02:28 PM

Could you describe your data further? How does the matrix enter into the model?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-08-2016 03:39 PM

I have 55 input variables in the data and 20 samples. so its 20*55. and y is a 1*55 matrix. so it is a vector. Many thanks for helping.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-08-2016 03:40 PM

I am so sorry y is a 1*20 matrix.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-08-2016 09:28 PM

Are your matrices SAS data sets - .sas7bdat files?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-09-2016 11:11 PM

No. It is a csv file.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-09-2016 11:27 PM

Please post a sample of your data. I think you can use proc glm.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2016 07:46 AM

I attached the data. There are 20 samples and 55 variables in the data. here is the output: Many thanks.

8.14 | 5.77 | 5.89 | 4.78 | 4.48 | 3.96 | 5.1 | 5.57 | 5.27 | 4.2 | 5.23 | 2.94 | 4.77 | 4.67 | 4.8 | 5.21 | 5.28 | 3.91 | 4.21 | 5.17 |

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2016 10:43 AM

This is how the code could look, if you wanted a simple GLM model:

```
*import dataset into SAS;
data have;
infile 'C:\_localdata\data.csv' dlm="," dsd truncover lrecl=1000;
informat var1-var40 best32.;
format var1-var40 best32.;
input var1-var40;
run;
*Run model;
proc glm data=have;
model var1 = var2--var40;
run;quit;
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2016 12:47 PM

Many thanks for your response. I have some questions for you. Where is the output variable 'y'. Also why did you take 40 variables is there a specific reason for that?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2016 01:09 PM

Your file had 40 variables, it was a demo of how it could be accomplished.

It had no headers so I don't know which is y, which is x etc.

I simply took the first variable as the Y and the remaining as X to demonstrate the GLM procedure.

To develop a final model you might want to use a selection method to subset the variables. PROC GLMSELECT is helpful here.

Please consider my code a sample, not what you should do. You should know what your variables are and how they should be handled.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2016 01:17 PM

Many thanks for your response I understood you mean.

My bad. Mistakengly I put 55*40 input. It should be 55*20 but I see you mean. The 40 is the sample number. I do have 55 variables so is the following right?

```
proc glm data=have;
model y = var1--var55;
run;quit;
```

I don't now what GLMSLECT is doing at the final stage. I will research for it. Many thanks for your responses.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2016 01:28 PM

You had 55 observations, not variables.

The columns are variables not rows

In general, your code looks correct, assuming that matches your data structure.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2016 03:19 PM

Thank you so much so I need to transpoze my data in order to make right model. Many thanks.