Assigning Member to Level With Code

Which functions (code) can I use to dynamically assign a member to a specific level?

I'm currently using:

$member = new M_Membership($guest->ID);
                    $member->subscriptions = "";
                    $member->assign_level(1)

but to no avail.
Thanks.